PHP-CSL V0.9

 +PHP
+ Arrays (4)
+ COM for Windows (2)
+ Image (2)
+ LDAP (3)
+ MySQL (10)
+ Regular Expressions (2)
+ String Manipulation (11)
+ Case
+ Crypt
+ Currency
+ Decoding HTML Entities
+ Echo
+ Explode
+ Implode
+ Parsing a Query String
+ Sorting Strings
+ Sub String Replace
+ Trim
+ Time and Date (6)
 +Snippet Options
+   Printer Friendly
 +Library Options
+   View Other Library
 +General Options
+   Library Home
+   PHP-CSL Credits
+   PHP-CSL License
+   Resource Links
+   Log in
Syntax for: String Manipulation / Sub String Replace

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:

<?php

$var 
'ABCDEFGH:/MNRPQR/';
echo 
"Original: $var<hr>n";

/* These two examples replace all of $var with 'bob'. */
echo substr_replace($var'bob'0) . "<br>n";
echo 
substr_replace($var'bob'0strlen($var)) . "<br>n";

/* Insert 'bob' right at the beginning of $var. */
echo substr_replace($var'bob'00) . "<br>n";

/* These next two replace 'MNRPQR' in $var with 'bob'. */
echo substr_replace($var'bob'10, -1) . "<br>n";
echo 
substr_replace($var'bob', -7, -1) . "<br>n";

/* Delete 'MNRPQR' from $var. */
echo substr_replace($var''10, -1) . "<br>n";
?>
 
Description for: String&nbsp;Manipulation / Sub&nbsp;String&nbsp;Replace
  Replace text within a portion of a string


 
Powered by: PHP-CSL V0.9