Showing posts with label substr_replace(). Show all posts
Showing posts with label substr_replace(). Show all posts

Friday 27 July 2012

PHP substr_replace()



<?php
    $id = "asdfasdf";
    $id = substr_replace( $id, "00", 3, 2);
    print "New id number: $id<br/>";
?>

Output:

New id number: asd00sdf


<?php
$mystring = substr_replace("Hello World", "asdf", 0, 0);
echo $mystring . "<br />"; 

$mystring = substr_replace("Hello World", "0 w0", 4, 4);
echo $mystring;
?>

Output :

asdfHello World
Hell0 w0rld
<?php
$favs = " is good boy.";
$name = "Ram";
$favs = substr_replace($favs, $name, 0, 0);
print $favs;
?>

Output :

Ram is good boy.