PHP 7.2.0 Release Candidate 2 Released

str_replace

(PHP 4, PHP 5, PHP 7)

str_replaceRemplace toutes les occurrences dans une chaîne

Description

mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

str_replace() retourne une chaîne ou un tableau, dont toutes les occurrences de search dans subject ont été remplacées par replace.

Si vous n'avez pas besoin de règles de remplacement compliquées (comme les expressions rationnelles), utilisez cette fonction au lieu de la fonction preg_replace().

Liste de paramètres

Si les paramètres search et replace sont des tableaux, alors la fonction str_replace() prendra une valeur de chaque tableau et les utilisera pour la recherche et le remplacement sur subject. Si les paramètres replace a moins de valeurs que le paramètre search, alors une chaîne de caractères vide sera utilisée comme valeur pour le reste des valeurs de remplacement. Si le paramètre search est un tableau et que le paramètre replace est une chaîne de caractères, alors cette chaîne de caractères de remplacement sera utilisée pour chaque valeur de search. L'inverse n'a pas de sens.

Si search ou replace sont des tableaux, les éléments sont traités du premier, au dernier.

search

La valeur à chercher, autrement connue comme le masque. Un tableau peut être utilisé pour désigner plusieurs masques.

replace

La valeur de remplacement à substituer aux valeurs trouvées. Un tableau peut être utilisé pour désigner plusieurs valeurs de remplacement.

subject

La chaîne de caractères ou le tableau sur lequel on va effectuer la recherche et le remplacement, aussi connu sous le nom de haystack.

Si subject est un tableau, alors le remplacement se fera sur chaque élément de celui-ci, et la valeur retournée sera aussi un tableau.

count

Si fournie, cette variable contiendra le nombre de remplacements effectués.

Valeurs de retour

Cette fonction retourne une chaîne, ou un tableau, contenant les valeurs remplacées.

Exemples

Exemple #1 Exemple 1 avec str_replace()

<?php
// Génère : <body text='black'>
$bodytag str_replace("%body%""black""<body text='%body%'>");

// Génère : Hll Wrld f PHP
$vowels = array("a""e""i""o""u""A""E""I""O""U");
$onlyconsonants str_replace($vowels"""Hello World of PHP");

// Génère : You should eat pizza, beer, and ice cream every day
$phrase  "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits""vegetables""fiber");
$yummy   = array("pizza""beer""ice cream");

$newphrase str_replace($healthy$yummy$phrase);

// Génère : 2
$str str_replace("ll""""good golly miss molly!"$count);
echo 
$count;

?>

Exemple #2 Exemple 2 avec str_replace()

<?php
// Ordre des remplacements
$str     "Line 1\nLine 2\rLine 3\r\nLine 4\n";
$order   = array("\r\n""\n""\r");
$replace '<br />';

// Traitement du premier \r\n, ils ne seront pas convertis deux fois.
$newstr str_replace($order$replace$str);

// Affiche F car A est remplacé par B, puis B est remplacé par C, et ainsi de suite...
// Finalement, E est remplacé par F
$search  = array('A''B''C''D''E');
$replace = array('B''C''D''E''F');
$subject 'A';
echo 
str_replace($search$replace$subject);

// Affiche : apearpearle pear
// Pour les mêmes raisons que plus haut
$letters = array('a''p');
$fruit   = array('apple''pear');
$text    'a p';
$output  str_replace($letters$fruit$text);
echo 
$output;
?>

Notes

Note: Cette fonction gère les chaînes binaires.

Attention

Ordre de remplacement

A cause du fait que la fonction str_replace() effectue les remplacements de la gauche vers la droite, elle peut remplacer une valeur précédemment insérée lors de multiples remplacements.

Note:

Cette fonction est sensible à la casse. Utilisez la fonction str_ireplace() pour un remplacement insensible à la casse.

Voir aussi

add a note add a note

User Contributed Notes 45 notes

up
157
nikolaz dot tang at hotmail dot com
6 years ago
A faster way to replace the strings in multidimensional array is to json_encode() it, do the str_replace() and then json_decode() it, like this:

<?php
function str_replace_json($search, $replace, $subject){
     return
json_decode(str_replace($search, $replacejson_encode($subject)));

}
?>

This method is almost 3x faster (in 10000 runs.) than using recursive calling and looping method, and 10x simpler in coding.

Compared to:

<?php
function str_replace_deep($search, $replace, $subject)
{
    if (
is_array($subject))
    {
        foreach(
$subject as &$oneSubject)
           
$oneSubject = str_replace_deep($search, $replace, $oneSubject);
        unset(
$oneSubject);
        return
$subject;
    } else {
        return
str_replace($search, $replace, $subject);
    }
}
?>
up
37
Wes Foster
7 years ago
Feel free to optimize this using the while/for or anything else, but this is a bit of code that allows you to replace strings found in an associative array.

For example:
<?php
$replace
= array(
'dog' => 'cat',
'apple' => 'orange'
'chevy'
=> 'ford'
);

$string = 'I like to eat an apple with my dog in my chevy';

echo
str_replace_assoc($replace,$string);

// Echo: I like to eat an orange with my cat in my ford
?>

Here is the function:

<?php
function strReplaceAssoc(array $replace, $subject) {
   return
str_replace(array_keys($replace), array_values($replace), $subject);   
}
?>

[Jun 1st, 2010 - EDIT BY thiago AT php DOT net: Function has been replaced with an updated version sent by ljelinek AT gmail DOT com]
up
25
Alberto Lepe
8 years ago
Be careful when replacing characters (or repeated patterns in the FROM and TO arrays):

For example:

<?php
$arrFrom
= array("1","2","3","B");
$arrTo = array("A","B","C","D");
$word = "ZBB2";
echo
str_replace($arrFrom, $arrTo, $word);
?>

I would expect as result: "ZDDB"
However, this return: "ZDDD"
(Because B = D according to our array)

To make this work, use "strtr" instead:

<?php
$arr
= array("1" => "A","2" => "B","3" => "C","B" => "D");
$word = "ZBB2";
echo
strtr($word,$arr);
?>

This returns: "ZDDB"
up
29
moostende at gmail dot com
5 years ago
Note that this does not replace strings that become part of replacement strings. This may be a problem when you want to remove multiple instances of the same repetative pattern, several times in a row.

If you want to remove all dashes but one from the string '-aaa----b-c-----d--e---f' resulting in '-aaa-b-c-d-e-f', you cannot use str_replace. Instead, use preg_replace:

<?php
$challenge
= '-aaa----b-c-----d--e---f';
echo
str_replace('--', '-', $challenge).'<br>';
echo
preg_replace('/--+/', '-', $challenge).'<br>';
?>

This outputs the following:
-aaa--b-c---d-e--f
-aaa-b-c-d-e-f
up
11
mrrehbein at gmail dot com
2 years ago
nikolaz dot tang at hotmail dot com's solution of using json_encode/decode is interesting, but a couple of issues to be aware of with it.

<?php
// From: nikolaz dot tang at hotmail dot com's post
function str_replace_json($search, $replace, $subject){
     return
json_decode(str_replace($search, $replacejson_encode($subject)));
}
?>

json_decode will return objects, where arrays are probably expected.  This is easily remedied by adding 2nd parameter 'true' to json_decode.

$search and $replace could contain strings that match json encoding, which will either change the structure returned by this method, or break the json.

ie:
<?php
var_dump
(str_replace_json('":"', '","', ['this' => 'stuff']));
var_dump(str_replace_json('this":"', 'this" : "thing", "with":"', ['this' => 'stuff']));
?>
up
9
pjcdawkins at googlemail dot com
7 years ago
Here's a deep replace function allowing multi-dimensional arrays in $search, $replace and $subject. The keys and other structure of $subject are preserved.

<?php
// Auxiliary function:
function _replaceWithAnything($search,$replace,$subject){
  if(!
is_array($search) || !is_array($replace)){
   
$search=array($search);
   
$replace=array($replace);
  }
 
$match=array_search($subject,$search,true);
  if(
$match!==false && array_key_exists($match,$replace))
   
$subject=$replace[$match];
  return
$subject;
}

// Main function:
function deepReplace($search,$replace,$subject){
  if(!
is_array($subject))
    return
_replaceWithAnything($search,$replace,$subject);
  foreach(
$subject as &$val){
    if(
is_array($val)){
     
$val=deepReplace($search,$replace,$val);
      continue;
    }
   
$val=_replaceWithAnything($search,$replace,$val);
  }
  return
$subject;
}
?>
up
1
viundan at gmail dot com
1 year ago
Decision to avoid problem "it might replace a previously inserted value when doing multiple replacements. See also the examples in this document."

$urls - array of urls i want to replace with tag <a> and urls could be similar
http://abc.com/parameter/
http://abc.com/

// at first sort by length to have longest firstly
usort($urls,'sortByLen');

$replaces=[];

// replace all urls with unique
foreach($urls as $url){
    $replace = '__REPLACE' . uniqid() . '__';    
    $text = str_replace($url,$replace, $text);
    $replaces[$replace] = '<a href="' . $url . '">' . $url . '</a>';
}

foreach($replaces as $key => $replace){
    $text = str_replace($key,$replace, $text);
}

--------------

function sortByLen($a,$b){
    return strlen($b)-strlen($a);
}

Hope it will help others like me
up
10
David Holt
1 year ago
Be aware that if you use this for filtering & sanitizing some form of user input, or remove ALL instances of a string, there's another gotcha to watch out for:

// Remove all double characters
$string="1001011010";
$string=str_replace(array("11","00"),"",$string);
// Output: "110010"

$string="<ht<html>ml> Malicious code </<html>html> etc";
$string=str_replace(array("<html>","</html>"),"",$string);
// Output: "<html> Malicious code </html> etc"
up
12
jay_knows_(all)uk at hotmail dot com
6 years ago
This strips out horrible MS word characters.

Just keep fine tuning it until you get what you need, you'll see ive commented some out which caused problems for me.

There could be some that need adding in, but its a start to anyone who wishes to make their own custom function.

<?php

function msword_conversion($str)
{
$str = str_replace(chr(130), ',', $str);    // baseline single quote
$str = str_replace(chr(131), 'NLG', $str);  // florin
$str = str_replace(chr(132), '"', $str);    // baseline double quote
$str = str_replace(chr(133), '...', $str);  // ellipsis
$str = str_replace(chr(134), '**', $str);   // dagger (a second footnote)
$str = str_replace(chr(135), '***', $str);  // double dagger (a third footnote)
$str = str_replace(chr(136), '^', $str);    // circumflex accent
$str = str_replace(chr(137), 'o/oo', $str); // permile
$str = str_replace(chr(138), 'Sh', $str);   // S Hacek
$str = str_replace(chr(139), '<', $str);    // left single guillemet
// $str = str_replace(chr(140), 'OE', $str);   // OE ligature
$str = str_replace(chr(145), "'", $str);    // left single quote
$str = str_replace(chr(146), "'", $str);    // right single quote
// $str = str_replace(chr(147), '"', $str);    // left double quote
// $str = str_replace(chr(148), '"', $str);    // right double quote
$str = str_replace(chr(149), '-', $str);    // bullet
$str = str_replace(chr(150), '-–', $str);    // endash
$str = str_replace(chr(151), '--', $str);   // emdash
// $str = str_replace(chr(152), '~', $str);    // tilde accent
// $str = str_replace(chr(153), '(TM)', $str); // trademark ligature
$str = str_replace(chr(154), 'sh', $str);   // s Hacek
$str = str_replace(chr(155), '>', $str);    // right single guillemet
// $str = str_replace(chr(156), 'oe', $str);   // oe ligature
$str = str_replace(chr(159), 'Y', $str);    // Y Dieresis
$str = str_replace('°C', '&deg;C', $str);    // Celcius is used quite a lot so it makes sense to add this in
$str = str_replace('£', '&pound;', $str);
$str = str_replace("'", "'", $str);
$str = str_replace('"', '"', $str);
$str = str_replace('–', '&ndash;', $str);

return
$str;
}

?>
up
5
michael dot moussa at gmail dot com
8 years ago
As previous commentators mentioned, when $search contains values that occur earlier in $replace, str_replace will factor those previous replacements into the process rather than operating solely on the original string.  This may produce unexpected output.

Example:

<?php
$search
= array('A', 'B', 'C', 'D', 'E');
$replace = array('B', 'C', 'D', 'E', 'F');
$subject = 'ABCDE';

echo
str_replace($search, $replace, $subject); // output: 'FFFFFF'
?>

In the above code, the $search and $replace should replace each occurrence in the $subject with the next letter in the alphabet.  The expected output for this sample is 'BCDEF'; however, the actual output is 'FFFFF'.

To more clearly illustrate this, consider the following example:

<?php
$search
= array('A', 'B', 'C', 'D', 'E');
$replace = array('B', 'C', 'D', 'E', 'F');
$subject = 'A';

echo
str_replace($search, $replace, $subject); // output: 'F'
?>

Since 'A' is the only letter in the $search array that appears in $subject, one would expect the result to be 'B'; however, replacement number $n does *not* operate on $subject, it operates on $subject after the previous $n-1 replacements have been completed.

The following function utilizes array_combine and strtr to produce the expected output, and I believe it is the most efficient way to perform the desired string replacement without prior replacements affecting the final result.

<?php
/**
* When using str_replace(...), values that did not exist in the original string (but were put there by previous
* replacements) will be replaced continuously.  This string replacement function is designed replace the values
* in $search with those in $replace while not factoring in prior replacements.  Note that this function will
* always look for the longest possible match first and then work its way down to individual characters.
*
* The "o" in "stro_replace" represents "original", indicating that the function operates only on the original string.
*
* @param array $search list of strings or characters that need to be replaced
* @param array $replace list of strings or characters that will replace the corresponding values in $search
* @param string $subject the string on which this operation is being performed
*
* @return string $subject with all substrings in the $search array replaced by the values in the $replace array
*/
function stro_replace($search, $replace, $subject)
{
    return
strtr( $subject, array_combine($search, $replace) );
}

$search = array('A', 'B', 'C', 'D', 'E');
$replace = array('B', 'C', 'D', 'E', 'F');
$subject = 'ABCDE';

echo
stro_replace($search, $replace, $subject); // output: 'BCDEF'
?>

Some other examples:

<?php
$search
= array(' ', '&');
$replace = array('&nbsp;', '&amp;');
$subject = 'Hello & goodbye!';

// We want to replace the spaces with &nbsp; and the ampersand with &amp;
echo str_replace($search, $replace, $subject); // output: "Hello&amp;nbsp&amp;&amp;nbspgoodbye!" - wrong!

echo stro_replace($search, $replace, $subject); // output: "Hello&nbsp;&amp;&nbsp;goodbye!" - correct!

/*
    Note:  Run the above code in the CLI or view source on your web browser - the replacement strings for stro_replace are HTML entities which the browser interprets.
*/
?>

<?php
$search
= array('ERICA', 'AMERICA');
$replace = array('JON', 'PHP');
$subject = 'MIKE AND ERICA LIKE AMERICA';

// We want to replace the name "ERICA" with "JON" and the word "AMERICA" with "PHP"
echo str_replace($search, $replace, $subject); // output: "MIKE AND JON LIKE AMJON", which is not correct

echo stro_replace($search, $replace, $subject); // output: "MIKE AND JON LIKE PHP", which is correct
?>
up
9
jbarnett at jmbelite dot com
7 years ago
Might be worth mentioning that a SIMPLE way to accomplish Example 2 (potential gotchas) is to simply start your "replacements" in reverse.

So instead of starting from "A" and ending with "E":

<?php
$search 
= array('A', 'B', 'C', 'D', 'E');
$replace = array('B', 'C', 'D', 'E', 'F');
// replaces A to B, B to C, C to D, D to E, E to F (makes them all F)
// start from "E" and end with "A":

$search  = array('E', 'D', 'C', 'B', 'A');
$replace = array('F', 'E', 'D', 'C', 'B');
// replaces E to F, D to E, C to D, B to C, A to B (prevents from
// multiple replacements of already replaced values)
?>

So basically start from the "end" and put the replacements in an order where the "replaced value" won't equal a value that exists later in the "search array".
up
3
Ing. Mirko Plazotta
3 years ago
<?php
// a very beatiful way to do multiple replacements is this one, using just one array
$replaceThis = Array(
'old word' => 'new word',
'was' => 'it',
'past' => 'future',
);

$originalText = "every old word was a thing of the past...";
$replacedText = str_replace(array_keys($replaceThis), $replaceThis, $originalText);
echo
$replacedText;
?>
up
3
matt wheaton
11 years ago
As an effort to remove those Word copy and paste smart quotes, I've found that this works with UTF8 encoded strings (where $text in the following example is UTF8). Also the elipsis and em and en dashes are replaced.

There is an "invisible" character after the †for the right side double smart quote that doesn't seem to display here. It is chr(157).

<?php
  $find
[] = '“'// left side double smart quote
 
$find[] = '”'// right side double smart quote
 
$find[] = '‘'// left side single smart quote
 
$find[] = '’'// right side single smart quote
 
$find[] = '…'// elipsis
 
$find[] = '—'// em dash
 
$find[] = '–'// en dash

 
$replace[] = '"';
 
$replace[] = '"';
 
$replace[] = "'";
 
$replace[] = "'";
 
$replace[] = "...";
 
$replace[] = "-";
 
$replace[] = "-";

 
$text = str_replace($find, $replace, $text);
?>
up
2
Denzel Morris
5 years ago
Maybe obvious to veteran PHP programmers but less so to novice PHP programmers is the fact that this is invalid:
<?php
str_replace
($search, $replace, $subject, 1);
?>
At a glance it appears to be a reasonable request, until you realize that the fourth parameter must be a variable in order to be passed as a reference. A replacement:
<?php
str_replace
($search, $replace, $subject, $temp = 1);
// or
$temp = 1;
str_replace($search, $replace, $subject, $temp);
?>
up
2
kriscraig at php dot net
5 years ago
<?php

/**
* Convert foreign 8859-1 characters into HTML entities.
*
* @param string $str
*   The string being parsed.
*
* @return string
*   The converted string.
*/
public static function convert_chars_to_entities( $str )
{
   
$str = str_replace( 'À', '&#192;', $str );
   
$str = str_replace( 'Á', '&#193;', $str );
   
$str = str_replace( 'Â', '&#194;', $str );
   
$str = str_replace( 'Ã', '&#195;', $str );
   
$str = str_replace( 'Ä', '&#196;', $str );
   
$str = str_replace( 'Å', '&#197;', $str );
   
$str = str_replace( 'Æ', '&#198;', $str );
   
$str = str_replace( 'Ç', '&#199;', $str );
   
$str = str_replace( 'È', '&#200;', $str );
   
$str = str_replace( 'É', '&#201;', $str );
   
$str = str_replace( 'Ê', '&#202;', $str );
   
$str = str_replace( 'Ë', '&#203;', $str );
   
$str = str_replace( 'Ì', '&#204;', $str );
   
$str = str_replace( 'Í', '&#205;', $str );
   
$str = str_replace( 'Î', '&#206;', $str );
   
$str = str_replace( 'Ï', '&#207;', $str );
   
$str = str_replace( 'Ð', '&#208;', $str );
   
$str = str_replace( 'Ñ', '&#209;', $str );
   
$str = str_replace( 'Ò', '&#210;', $str );
   
$str = str_replace( 'Ó', '&#211;', $str );
   
$str = str_replace( 'Ô', '&#212;', $str );
   
$str = str_replace( 'Õ', '&#213;', $str );
   
$str = str_replace( 'Ö', '&#214;', $str );
   
$str = str_replace( '×', '&#215;', $str );  // Yeah, I know.  But otherwise the gap is confusing.  --Kris
   
$str = str_replace( 'Ø', '&#216;', $str );
   
$str = str_replace( 'Ù', '&#217;', $str );
   
$str = str_replace( 'Ú', '&#218;', $str );
   
$str = str_replace( 'Û', '&#219;', $str );
   
$str = str_replace( 'Ü', '&#220;', $str );
   
$str = str_replace( 'Ý', '&#221;', $str );
   
$str = str_replace( 'Þ', '&#222;', $str );
   
$str = str_replace( 'ß', '&#223;', $str );
   
$str = str_replace( 'à', '&#224;', $str );
   
$str = str_replace( 'á', '&#225;', $str );
   
$str = str_replace( 'â', '&#226;', $str );
   
$str = str_replace( 'ã', '&#227;', $str );
   
$str = str_replace( 'ä', '&#228;', $str );
   
$str = str_replace( 'å', '&#229;', $str );
   
$str = str_replace( 'æ', '&#230;', $str );
   
$str = str_replace( 'ç', '&#231;', $str );
   
$str = str_replace( 'è', '&#232;', $str );
   
$str = str_replace( 'é', '&#233;', $str );
   
$str = str_replace( 'ê', '&#234;', $str );
   
$str = str_replace( 'ë', '&#235;', $str );
   
$str = str_replace( 'ì', '&#236;', $str );
   
$str = str_replace( 'í', '&#237;', $str );
   
$str = str_replace( 'î', '&#238;', $str );
   
$str = str_replace( 'ï', '&#239;', $str );
   
$str = str_replace( 'ð', '&#240;', $str );
   
$str = str_replace( 'ñ', '&#241;', $str );
   
$str = str_replace( 'ò', '&#242;', $str );
   
$str = str_replace( 'ó', '&#243;', $str );
   
$str = str_replace( 'ô', '&#244;', $str );
   
$str = str_replace( 'õ', '&#245;', $str );
   
$str = str_replace( 'ö', '&#246;', $str );
   
$str = str_replace( '÷', '&#247;', $str );  // Yeah, I know.  But otherwise the gap is confusing.  --Kris
   
$str = str_replace( 'ø', '&#248;', $str );
   
$str = str_replace( 'ù', '&#249;', $str );
   
$str = str_replace( 'ú', '&#250;', $str );
   
$str = str_replace( 'û', '&#251;', $str );
   
$str = str_replace( 'ü', '&#252;', $str );
   
$str = str_replace( 'ý', '&#253;', $str );
   
$str = str_replace( 'þ', '&#254;', $str );
   
$str = str_replace( 'ÿ', '&#255;', $str );
   
    return
$str;
}
?>
up
0
vuabid at hotmail dot com
13 days ago
Consider this while using str_replace function when $search and $replace are arrays.

$search = array( 'login_reactivate', 'login_reactivate_date' );
$replace = array( 'login reactivate status', 'login reactivate date' );
$subject = "fname, email, login_reactivate, login_reactivate_date";

$returnValue = str_replace( $search, $replace, $subject );

$returnValue will be:
fname, email, login reactivate status, login reactivate status_date

You can see we are expecting "login_reactivate_date" to be replaced with "login reactivate date" but it will replace to "login reactivate status_date"
up
1
flame2000 at mail dot ru
11 months ago
Replace chars in multi-byte string.
In example, replacing 'f'=>'b', 'o'=>'e', 't'=>'r' and etc.

<?php
function mb_chars_replace($from, $to, $subj, $delSymb='_') {
    
$nsubj='';
    
preg_match_all('/(.)/u', $subj, $subj);$subj=$subj[1];
     if (!
is_array($from)) {preg_match_all('/(.)/u', $from, $from);$from=$from[1];}
     if (!
is_array($to)) {preg_match_all('/(.)/u', $to, $to);$to=$to[1];}
     if (
count($from)!==count($to)) return false;

     foreach(
$subj as $s) {
       foreach(
$from as $k=>$f) {
         if(
$s===$f) {
                   
$s=$to[$k];
                    break;
         }
       }
       if(
$s!==$delSymb) $nsubj.=$s;
     }
    return
$nsubj;
}

//examples:

$from="fotber, ";
$to="berfot+_";

// or

$from=array("f","o","t","b","e","r",","," ");
$to=array("b","e","r","f","o","t","+","_");

//out:
echo mb_chars_replace($from,$to,"foot, beer"); //beer+foot
?>
up
-1
Anonymous
4 months ago
As others have written, the replaced part can be replaced again if one uses an associative array. If you simply want to replace a certain string with another one, this will work instead:

$string = 'A';
$replace = array( 'A' => 'B', 'B' => 'C');

foreach ($replace as $arraykey => $arrayvalue)
{
  if ($string === $arraykey)
  {
    $string = $arrayvalue;
    break;
  }
}
   
$string2 = 'A';
$string2 = str_replace(array_keys($replace), $replace, $string2);
   
echo $string; // B
echo $string2; // C
up
-1
info at 24h-workers dot de
4 months ago
I had problems with the import of text into a textarea field.
The line feed crashes the HTML Page. This solution helps:

$Text = str_replace(array("\r\n", "\r", "\n"), '\n', $Text);

Pay attention to single quote and double quote char.
up
0
Mohsin Ali (puregenius02 at gmail dot com)
1 year ago
$myString = “It was the best of mine it was the worst of mine,”;
// Displays “It was the best of bananas, it was the worst of bananas,”
echo str_replace( “mine”, “bananas”, $myString );
If you want to know how many times the search string was replaced, pass in a variable as an optional
fourth argument. After the function runs, this variable holds the number of replacements:
$myString = “It was the best of mine, it was the worst of mine,”;
// Displays “It was the best of bananas, it was the worst of bananas,”
echo str_replace( “mine”, “bananas”, $myString, $num ) . “ < br/ > ”;
// Displays “The text was replaced 2 times.”
echo “The text was replaced $num times. < br/ > ”;
up
0
borasahin at gmail dot com
2 years ago
jSON Turkish Characters Problem - (PHP < 5.4 for example)

<?php
function json_decode_tr($json){
      
$json_char = array("u00e7","u0131","u00fc","u011f","u00f6","u015f","u0130","u011e","u00dc","u00d6","u015e","u00c7");
      
$turkish = array("ç","ı","ü","ğ","ö","ş","İ","Ğ","Ü","Ö","Ş","Ç");
      
$result = str_replace($json_char, $turkish, $json);
       return
json_decode($json);
    }
?>
up
0
markem at sim1 dot us
3 years ago
I was working with MySQL and displaying the title to things on the web page.  I'd written a script to ensure single and double quotes were removed from the title.  I used

    $title = str_replace( "'", "", $title );

and

     $title = str_replace( '"', "", $title );

But still the single and double quotes continued.  So I wrote a bit of code to print out each character separated by a dash.  Like so:

     for( $i=0; $i<strlen($title); $i++ ){
         echo "$i-";
         }

     echo "<br>\n";

This displayed:

     m-y-c-o-m-p-a-n-y- b-b-&-#-3-9-;-s

Which made me go "Oh!  I get it."

The MySQL function real_escape_string modifies the single quotes to be &#39; and double quotes as &#34;  These still show up as single and double quotes under HTML and most importantly -

     JAVASCRIPT sees the &#34; and &#39; as actual single or double
     quotes.  So if you are passing arguments to a function you have
     to get rid of them or else you will get an error on trying to call
     a given function.  Example:

     <a href="javascript:func1('mycompany bbs&#39;s")'">

     becomes

     <a href="javascript:func1('mycompany bbs's');">

Which then will give you an error because there is a single quote inside of the single quoted string.  HOWEVER, the

     $title = str_replace( "'", "", $title );

WILL NOT FIND a single quote.  Instead, you have to do this:

     $title = str_replace( "&#39;", "'", $title );
and
     $title = str_relace( "&#34;", '"', $title );

(Or you could just get rid of them.)

So remember!  If you are trying to remove single and double quotes and are using MySQL and MySQL's real_escape_string() function that you might be having single and double quotes hanging around which are defined as &#39; and &#34; but which show up as single and double quotes as well as causing problems in your Javascripts.
up
0
mbullard at accuvista dot co dot uk
6 years ago
Insert space after comma.

If you have a form that stores results in a database field as comma separated values, when you display this data you can use the following to insert a space after each comma:

<?php
$find
[] = ',';
$replace[] = '&#44;&nbsp;';
$text = str_replace($find, $replace, $row_rsRecordset['Field']);
print_r($text);
?>

Notes:
1) To get round the Replacement Order Gotcha, the class=is also6an class="keyword">,
"u015e"&nsecpan>
&n classin y="defableble
amp;page=function.str-replace&vote=98511tle="Vote up!" class="usernotes-voteu">up
0
<98511>
6 years ago
a Insert space after comma.

If you havfe refield a you temrnotemma serintapan rnoteng =eacing curle yrotesmma seneedut it will replaiaceme <,mma:


$find
[] = span>json_decode_tr($find, $row_rsRecordset[?>
 an class="default">default">$fr?php
$myStrs {a}sin y{bc}imes.”Pa"arraykeyons="d"bc"arraykeytwo'
echo $string2; //span>[str_replace($find
, $row_rsRecordse
echo $string2; /ue)
/span>[$k=>str_replace=>
?>
&nbs        /span>[str_replace($find, <;
print_r<.ass="keyword">=>
print_r<.ass="keyword">=><;
$to, ?>
,
?> $nsubj;
}
//ex=array(
up
0 <770cla
6 years ago 09 12:2lass="text"10id="Hcom104890">

If you haW/spass="4.3.1,ss="least,e are arrays. this w upllowin things on thoblems itivat as wmegumetstrl.
wo[] = < />fnamepan class="string">"ç"
,"t","t",$to=array(< as an  /span>"t"[] = "+"[] = $result place($find, $replace, $row_rsRecordset[< />fnampan class="default">$to($text);
$to
<>
?& Abr / ( [0]arrayke_datshmber!eat="#at=[1]arrayke"#at=[2]arraykeaalso6at=everyd="H. )/span>span>json_declace[]han>raykpan>// or

[< />fnamepan class="string">"ç","+""t"&nbs                ,pan class="keyword">,"t","t"&nbs                ,pan class="keyword">,"t"$to>=array(< as an  /span>"t"[] = "+"[] = $result place($find, $replace, $row_rsRecordset[< />fnampan class="default">$to($text);
$to
<>
?& Abr / ( [0]arraykeAbr / [1]arraykeAbr / [2]arraykeAbr / )/span>span>
0 wn 48 ward at accuvista dot co dot uk ¶
02:42">6 years ago 5div c1ass="text"5id="Hcom104890">
a Insert space after comma.

If you havess in n clarle quotenumericas cos="="s1.000,33aiacelemn>  {
&nbs(39;pos($zahl,".")v> <"-1")v| (39;pos($zahl,",")v> <"-1")/r />&nbs    &nbs(39;pos($zahl,".")v> <"-1")vs-vot (39;pos($zahl,",")v> <"-1")/r />&nbs      &nbs39;pos($zahl,".")v> <39;pos($zahl,",") "$i-";
      &subj
&nb",","",$zahl)="default">?>&"$i-";
      &subj&nb",",".",and
&nb".","",$zahl)an>jsoan> $nsnbr />&"$i-";
    &n&nbs39;pos($zahl,".")v> <"-1")v"$i-";
      &s&nbs39;pos($zahl,".")v=>
jsoanbr />&"$i-";
      &subj
&nb".","",$zahl);br />      &subj      &sclass="default">is_aranbr />&"$i-";
      &s&nbs39;pos($zahl,",")v=>
&nb",",".",$zahl)="default">?>&"$i-";
      &subj
&nb",","",$zahl);br />      &subj      &sclass="default">is_aranbA';
&"$i-";
  &nan>
up
0 48
6 years ago
,ofhcausript toar will replng member!s=" "ord">"e uses an as"keywpan c easile yingle qreplacebe usireap; &nbsen you disptyStre', 'login_reAnywvau have"u015e"&ma:for"as1nbspas2nbspas3nbspflex"atus', 'login reactivate ");"><\"color:/">d;\"t;echo $strint and doublemyString,i arrays("%%ngle quot and double quoteInearch cdispI amreplace%%aus myitoke"\s suo="shfunctun hrebybbr /,lasbo><me /lass="note" id="104890">
up
0 48 <7234laward at accuvig>
6 years ago1-15

&n, make m theth anae insiress="n aaiacUTF-8d(NO BOM)e', 'login_re m-y-laces="leastwant st oy/div> < class="note" id="119293">
0 wn 45 ward at accuvista dot co dot uk ¶
08:04">3 years ago
a I was working with MySQL and displaying the ti"If&nas an hfunctpan c aalsogin reastring Displa singuo="ss an as"keyw39; and="slace><?veryd the st nas anreplesrinverss. tber!s=" make mens<,mmaougnrering modifiesIsriptkwant JAVASCRIP (aalss=" atstrl.vaguebyb sie)<?php
$fin"SELECT * FROM oy_tyStr WHERE (il$myStri when$8:04merersn stringThs="="sEXACTLYdma:
up
0 45 <73489award at accuvista dot co dot uk ¶
6 years ago2 5di5:48ass="text"10id="Hcom104890">
      &s>      &s"\xc2nbs// prefix 1li-";
      &s"\x80nbs// prefix 2li-";
      &s"\x98nbs// g.  HOWEopen.&nli-";
      &s"\x99nbs// g.  HOWEclos.&nli-";
      &s"\x8cnbs// v>
open.&nli-";
      &s"\x9d"bsp; &s// v>
clos.&nli-";
  &n)="default">?>  &n$goodchrbr />  &n>?>  &nand
&nb$badchr,n$goodchrring; FromExcelFinbsp; Instead, yothis wlt;me /lass="note" id="104890">
up
0 44 <979claward at accuvista dot co dot uk ¶
6 years ago

If you havfeth aneedut is will wor39; and=nn >$stri,aas wonlywancaaas wr HTML=nn TMLposst $findss="default"
json_decode_tr($text);
$row_rsRecordset
[<
$row_rsRecordset
[  {
ubj[< pln>place($json);
 span class="default">$row_rsRecordset
[echo $string2; //span>[str_replaceecho $string2; /ue)/>/span>[place($row_rsRecordset[place($find, $to<>[place["+"[$tor />&nbs        /span>[place(&nbsslilass="default">$find, $to[0ass="default">$row_rsRecordset[echo $string2; /    /span>[     /span>(&nbsslilass="default">$find, $to[echo $string2; /    / />echo $string2; /    /span>[( opss="default">$find, $to
r.
[<
[/>&nbsshifass="default">$find, ?>
[?>
[otheclass="default">$json);
 span class="default">$row_rsRecordset
[/>&nbsmergass="default">$json);
 previou$to,[?>
[?>
?>
$nsubj
;
} ?>
//ex
class="keyword">;
} $find
, $text
);"t""t""t"<>?& span clus m/span>p asbo or elsespan class="default"
elsespan clI" mayss=" benas,”
up
0 43
6 years ago

If you haTo collapse mv> ip
&nb)EVER, tha loop-- compreg
&nb)EVERteap; e)/br rity aalsbetrerspers cosn&n />$find
[] = span>$nsubj$nsubj$text = &nss="default">$text);$to, $to, $json(
0 wn 44 <8399">ward at accuvista dot co dot uk ¶
02:42">6 years ago
a Insert space after comma.

If you haYp;&nb$stri="#epis will wode_tr$find
[] =    /span>(&n_"#epss="default">$text, $replace, $row_rsRecordset[< />fnampan class="default">$to/span>    />&nbs        /span>[< />fnamepan class="string">"ç"(&nss="default">$text, $replace, $row_rsRecordset[< />fnampan class="default">$to
         &ue)
/span>[< />fnamepan class="string">"ç"[< the pan class="default">?>
[os_span is="default">$text, ?>
,
"ç"pan>(&n_"#epss="default">$text,
$replace, $row_rsRecordset[< the pan class="default">?>
echo $string2; /    an>;
}
fnampan class="default">$to?>
amp;page=function.str-replace&vote=86177tle="Vote up!" class="usernotes-voteu">up
0 wn 38 <86177>ward at accuvista dot co dot ukte ihref="#116797"> ¶
6 years ago
a I was working with MySQL and displaying the titlarled maxeakeefoxdesignsihref="#s array("\ e)/and
&n_ancaaas wit didn'th thi qui lace array("\( TMLp:04ms mnbspber39; ans) />$find
[] = sspan>(&n_ancass="default">$find, $replace, $row_rsRecordset[< />fnampan class="default">$to />&nbs    /span>["ç"($text);
fnampan class="default">$to[< as anass="default">$replace/>, "ç"(?>
&nbs        /span>[slass="default">$json);
fnampan class="default">$to);
$row_rsRecordset class="keyword">,
?>
[S; /span>slass="default">$json);
fnampan class="default">$to["ç"(, $replace)an>jsoa  an>;
} $replace
.ass="keyword">=>
$row_rsRecordse.ass="keyword">=>
S; pan class="default">$to?>&"$i-";
      &san>;
}
fnampan class="default">$to?>
amp;page=function.str-replace&vote=do0774tle="Vote up!" class="usernotes-voteu">up
0 wn 37 ward at accuvista dot co dot uk ¶
6 years ago
06 08:08ass="text" id="Hcom104890">
[] = ?**gin_re-*nond
fnampin_re-*n@8:04melar $span cl_n clasin_re-*n@an>fname er /span cls,tFALSEgivef the.sin_re-*//span>sspan>(&nss="default">$text);$replace
, $row_rsRecordset[< />fnampan class="default">$to[$to />&nbs    /span>[$row_rsRecordsebr />echo $string2; //>&nbs    /span>?& vali agobinpu=nbsp; {
ubj[< as an /span>&nbs the fss="default">$text[< as anass="default">$replace/>[< as anC cla /span>$find, $replace/>[< as anC clapan class="default">?>
&nbs        an>;
}
fnampan class="default">$to?>
,
"ç"[< pan class="default">?>
&nbs        /span>[[< pan class="default">?>
?>
,
?>
echo $string2; //span>[$find, $row_rsRecordse);br />  &nr />echo $string2; //span>[,[$row_rsRecordse) :n>$text[$row_rsRecordse);> , =>"+" =>?>
&nbs        if (!/span>[is_r&nbyStrss="default">$find, ?>
=>$find
, $find
, $to, $find, ?>
["+"jsoa  n> &nbs    /span>?& as aneaalsogin re[< />fnamIsSnd I'd/span>$json);
fnampan class="default">$to
[< />fnamepan class="string">"ç"[< />fnampan class="default">$to?>, fnamepan class="string">"ç"[&nbs        if (!/span>[is_n>$json);
jsoa  ue)
,
"ç",
str_replace=>
$find
[;<ç"(, $find&nbs                rintinuenho $string2; /       / />echo $string2; /    ho $string2; //span>[, str_replace$row_rsRecordsebho $string2; /       / />echo $string2; /    ho $string2; //span>[place($row_rsRecordsebr />echo $string2; /ing2; /ing2; /ing2; /ing2; /whilen class="keyword">, "ç"(place($text);
[edtrss="default">$find[$text[, $row_rsRecordse[ class="keyword">, $row_rsRecordse]) ?n>$find, $row_rsRecordse[ class="keyword">, $row_rsRecordse]t[edtrss="default">$find[$row_rsRecordse) :n>$text [slaspan class="default">$find, [$find[$text[ jsoa  n> , echo $string2; //>&nbs    an>;
}
fnamIsSnd I'd/span>$json);
fnampan class="default">$to
$to
up
0 35
6 years ago
1-29 03:19ass="text" id="Hcom104890">
[] = < span>,"t","t"
<,"t","t" ($find, $replace< class="keyword">, $row_rsRecordselass="keyword">,"t"
> lacelitron snippe replnoleldma: : > [] = < span>"t"($find, $replace< class="keyword">, $replace< class="keyword">, $to span><{n>$text =>$json);$to=>&nbsmapss="default">$json); lass="default">$to, $text=>$to > [&nbslasbinepan class="default">?>
,
$replace
< class="keyword">,
$replace
)> > ;
} &n_r&nbbackaan class="default">?>
,
$find, ?>
, $replace< class="keyword">, $replace) {pan>;
} $row_rsRecordse[ class="keyword">,
?>
, $row_rsRecordse]] &n< class="keyword">, $to> > ($find, $replace< class="keyword">, $row_rsRecordselass="keyword">,"t"
>
up
0 33
6 years ago
$find[] = span>str_replace$text = str_replace$text , "t"= "t"?/Make s an as"keywpan c>
<,$to=>$to&nbs    pan class="keyword">,$to=>$to&nbs    pan class="keyword">,$to=>$to&nbs    pan class="keyword">,$to=>$to&nbs    pan class="keyword">,$to=>$to&nbs    pan class="keyword">,$to=>$to&nbs>(default">?/r&nb"t"($text, , "t"($text, ["t"&nbs    /span>[[0ass="default">$row_rsRecordsebr />echo $string2; /for>/span>[[0ass="default">$row_rsRecordseb[$row_rsRecordse">[]>(, [, , ["t", , $row_rsRecordse]) />&nbs    an>[, ["t", , $row_rsRecordse];br />  &nrn class="keyword">(default">?/make s an as"key/>&nbs    an>[(default">?/incrs"key/indexist s an as"keywpan c> , , $find, "t", $row_rsRecordse)) break;br />  &nrn class="keyword">(default">?/break ouahe&nbs        /span>;
}
0 35 <91035aw
6 years ago
[] = < >
default">?* > wpan c > "t"(
$find, [[< youass="default">$row_rsRecordse) { />&nbs    if (/span>[os_span is="default">$text[< youass="default">$row_rsRecordse)) { />&nbs    ho $string2; /for
/span>[< youepan class="string">"ç", str_replace=>
?>
&nbs    ho $string2; /    if (/span>[os_span is="default">$text[< the pan class="default">?>
&nbs    ho $string2; /        /span>[s curste _span span class="default">$find, [[< youass="default">$row_rsRecordse[ class="keyword">, $row_rsRecordse]); />&nbs    ho $string2; /    nbr />&" />&nbs    ho $string2; /        /span>[< youass="default">$row_rsRecordse[ class="keyword">, $row_rsRecordse]nbsp;'[andspan class="default">$find, [[< the pan class="default">?>
/>&nbs    ho $string2; /    n />&nbs    ho $string2; /n />&nbs    nbr />&" />&nbs    ho $string2; //span>[< youepan class="string">"ç"[andspan class="default">$find, [[< youass="default">$row_rsRecordse)> />&nbs    } > ;
} $row_rsRecordse[ class="keyword">, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t"
<$row_rsRecordse[ class="keyword">, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t"
<$row_rsRecordse[ class="keyword">, $to, $to"t" "t"
$json);
$row_rsRecordse)> />&nbs >
$find, "t""t"$row_rsRecordse)> />&nbs > class=s"ss="string">"t"
$json);
$row_rsRecordse)> />&nbs class="keyword">);
up
0 31
6 years ago 10 06:27ass="text"5id="Hcom104890">

If you haTlaceode_tr&nl);eis 100% backwardf="#patiStri er /and
&nl);e/emsmand
&nb)Ewhen?ver possiStri( e)/pers cosn&n reasons);esupVASCsnpan cs\ e)/a as an, $span cl, aals< />fnam; aalsaceod 0 defaultede', 'login_ren>[] =
?**gin_re-*n class= $limit\occurencesist uoteaas an and I'd
le s an as"key/>&nbs-*n@8:04memixed/a as aneples the ebe usi as anep; e). Actpan c m c bee/emd to/>&nbs-*ndesignagobmv> ipedtrs./>&nbs-*n@8:04memixed/as will wT />s an as"keyw the e wat=spn clasdfs als as anain_re-*n the f. Actpan c m c bee/emd tondesignagobmv> ip&nbs-*n@8:04memixed/a />fnameToteand I'dhe aan c be usi as anep;aalsogin relsan. If/>&nbs-*n />fnameis actpan c,tuotn uoteaas an aalsogin reeis pers coels
&nbs-*nkeyrc by />fnam, aals>le s >lacewillpber3e repl>le number of/>&nbs-*ns an as"keys pers coel./>&nbs-*n@8:04melar $limit\Totemaximum possiStris an as"keys e)/
nd=nn
&nbs-*n />fnameand I'. D"keywosrepl-1 (no limit)./>&nbs-*n@an>le s an asdn the f./>&nbs-*//span>sspan>(&n_limitss="default">$json);
$replace
, $row_rsRecordset[< />fnampan class="default">$to[$find[, $row_rsRecordse) />&nbs[$row_rsRecordsebr />ecnrn class="keyword">(default">?/ Invali $limit\provided/>&nbs;/span>);
$json
[andvalss="default">$json);
$json
);
$json
);
$json
&nbs   class="keyword">);
$find
, $text =>$json=>$text &nbs    /span>$to, $row_rsRecordse)>> ;
} fnampan class="default">$to (default">?/ Invali $limit\provided/>&nbs;/span>=>$json
[]- class="keyword">,
$row_rsRecordse) />&nbs   class="keyword">);
$find
, $text =>$json=>$text &nbs    /span>$to, $row_rsRecordse)>> ;
} fnampan class="default">$to (default">?/ Nois an as"keys necessary/>&nbs-/span>=>$json
[0ass="default">$row_rsRecordse) />&nbs   class="keyword">);
$find
, $text =>$json=>$text &nbs    /span>$to, $row_rsRecordse)>> ;
} fnampan class="default">$to (default">?/ Usemand
&nb)Ewhen possiStr/>&nbs-/span>=>$json
,
$row_rsRecordse) />&nbs  an>;
} $find
, $replace
, $row_rsRecordset[< />fnampan class="default">$to[$find =>$text
[< />fnampan class="default">$to&nbs   class="keyword">);?/ Loopsthrough/a />fname the fs>&nbs   class="keyword">);<>json_decoe)
,
fnamepan class="string">"ç", str_replace=>lac_ />fnampan class="default">$to&nbs     class="keyword">);?/ Skipe the fe wat=arenpan cs/>&nbs     class="keyword">);=>$text[<>lac_ />fnampan class="default">$to&nbs    /span>?/ C&nb&nbs    /span>[<>lac_ode_tr$to[< />fnampan class="default">$to, $row_rsRecordse]nbsp;'[<>lac_ode_tr$find, $replace, $row_rsRecordset[<>lac_ />fnampan class="default">$to[<>lac_n class="default">$find[$row_rsRecordse)>> ?/ Adjust $n cla"defau    /span>[[<>lac_n class="default">$find> ?/ Adjust $limita =>$json, $row_rsRecordse) />&nbs       class="keyword">);[[<>lac_n class="default">$find> ?/ R
=>$json
[0ass="default">$row_rsRecordse) />&nbs      an>;
}
fnampan class="default">$to?>
;
} fnampan class="default">$toifnass="keyword">=>
$text
[< as anass="default">$replace/) />&nbs   class="keyword">);?/ Cl="Hoce[< as an /span>&nbs the fss="default">$text[< as anass="default">$replace/;/>&nbs   class="keyword">);?/ Cl="Hoce=>$text[$row_rsRecordse)/ />&nbs     class="keyword">);[&nbs the fss="default">$text[$row_rsRecordse);> &nbs   class="keyword">);?/ Loopsthrough/a as anain_re  /span>, "ç", str_replace=>lac_ as anass="default">$replace/ />&nbs     class="keyword">);?/ Don'tesupVASCbmv> i-diaulsr&nbs     class="keyword">);lac_ as anepan class="string">"ç"[andvalss="default">$json);
lac_ as anass="default">$replace
/;/>&nbs     class="keyword">);?/ It $ogin reeis actpan c,t com$ogin re[akey];if exists,br />&''/>&nbs     class="keyword">);=>
$text
[$row_rsRecordse)/ />&nbs  an classifn class="keyword">, &nbssRe_existsis="default">$text[$row_rsRecordse, $row_rsRecordse)/ />&nbs  an clas   class="keyword">);lac_span cl /span>$json);
$row_rsRecordse[ class="keyword">,
$row_rsRecordse])="default">?>&"/>&nbs  an clas   class="keyword">);
lac_span cl /span>$text &"/>&nbs  an clas; class="keyword">);lac_span cl /span>$json);
$row_rsRecordse/;/>&nbs    n> ?/ C&nb&nbs     class="keyword">);lac_ode_tr
$to[< />fnamspan>lac_ode_tr$find, lac_ as anass="default">$replacet[<>lac_span class="default">$row_rsRecordset[< />fnampan class="default">$to[<>lac_n class="default">$find[$row_rsRecordse)>> ?/ Adjust $n cla"defau    /span>[[<>lac_n class="default">$find> ?/ Adjust $limita =>$json, $row_rsRecordse) />&nbs     class="keyword">);[[<>lac_n class="default">$find> ?/ R
=>$json
[0ass="default">$row_rsRecordse) />&nbs    an>;
}
fnampan class="default">$to?&  n> ;
} fnampan class="default">$to />&nbs   class="keyword">);[< as an /span>$json);
$replace
/;/>&nbs   class="keyword">);[$json);
$row_rsRecordse/;/>&nbs  /span>?/ Get posi>t[place($text);
fnampan class="default">$to[< as anass="default">$replace/;/>&nbs   class="keyword">);?/ Rn>fnamsit $ as an cans=" bedfs al=>$text
[nals ass="default">$replace/ />&nbs    an>;
}
fnampan class="default">$to?&g}/>&nbs   class="keyword">);?/ Get lengr /$t $ as anain_re  /span>[< as an_lenspan class="keyword">place(, $replace
/;/>&nbs   class="keyword">);?/ Loopsclail $ as an cans=" bedfs al e)/[[0ass="default">$row_rsRecordseb(>/span>[[]>($row_rsRecordse)||nass="keyword">=>$json, $row_rsRecordse))]>([< />fnamspan>slaspan class="default">$find, fnampan class="default">$to[$row_rsRecordset[$text[< as an_lenass="default">$row_rsRecordse)>> ?/ Incrsacom$n cla"defau    /span>[?/ Get loca>t[place($text);
fnampan class="default">$to[< as anass="default">$rew_rsRecordse)>> ?/ Break ouahe=>$text[nals ass="default">$replace/ />&nbs    break;"default">?&  n> ;
} fnampan class="default">$to
up
0 <8
6 years ago 19 10:01ass="text"4id="Hcom104890">

If you ha@moostendeenanchailshref="#1 [] =
($text);
$replace
)/span> />&nbs    do&"/>&nbs  an clas;    /span>[< ts /span>$find, "t""t"$replace,s/span>[$find?>, =>$row_rsRecordse)="default">?>;
} $replace
="defaun> ($text);"t"
up
0 <5 <85550a/
6 years ago

If you haFor PHP 4 ">[] 4.4.5 aalsPHP 5 ">[] 5.2.1ster m c occur ( hrefme)L=nnuois bug />$findhttp://wwwmp;v-s curity.org/MOPB/MOPB-39-http://wwwmp;v-s curity.org/MOPB/MOPB-39-
up
0 <5 <98370a/
6 years ago
$find[] = span>,$to$to$to$to= ,$to$to$text $to= $find, [$to
up
0 <5 <94073a/
6 years ago
[] = t;place$text ;
} $find, $text $text "t"
[] = t;place$text );
$text);
$text $text $replace/"defau    /span>[< /span>$find, $text $text "t"?/?ventstrlyr$cewillp=an'/pain_reon>
up
0 <1 <97374a/
6 years ago

If you haFast ode_tr s cost" i =nnHTMLaan>ri?veddfromn youbacomaalspan c I'di r
e', 'login_ren>[] =
default">?**gin_re-*n class= nlls hnabreaksr
&nbs-*n/>&nbs-*n@acnessipublic/>&nbs-*n@8:04meand I' $and I'/>&nbs-*lt">?&  Tlesode> toiberpronessel./>&nbs-*n@an>&nbs-*lt">?&  Tlesgiveneode>
&nbs-*//span>sspan>(
&n_new hnass="default">$text
);
$text &nbs  an>$find,
"t""t""t"$text $text
up
0 16 <87383aw
6 years ago2 02:55ass="text"8id="Hcom104890">

If you haRgin re"keyw e)/and
&ndindwhian admv> ipan clof numer ctrlyrtexedd youec/>te
&nbs > [] = < />&nbs >
>json_decode_tr(tess="default">$text);
$to[<>dm />tess="default">$text&nbs  ifmn class="keyword">,
dm />tess="default">$text?/ odm />te ts I' />&nbs    ss="default">$text, $text);
dm />tess="default">$text?/
&nbs    ho $stran>
>json_decoe)
, , $text?/
&nbs    ho $str  ss="default">$text
, $text);
$text?/ odsyw e)/digit />&nbs    ho $str    ss="default">$text, $text$row_rsRecordse)&";/span>?/ newadigiteaaquence />&nbs    ho $str      /span>[[< /span>$row_rsRecordse; />&nbs    ho $str    } />&nbs    ho $str    ss="default">$text["t", [$text?/ ste)< digit />&nbs    ho $str  ss="default">$text ;/span>?/ nrefa/digit />&nbs    ho $str    ss="default">$text, $text$row_rsRecordse)&";/span>?/ newanon-digiteaaquence />&nbs    ho $str      /span>[[< /span>$row_rsRecordse; />&nbs    ho $str    } />&nbs    ho $str    ss="default">$text[< ts I' ss="string">"t", [$text?/ ste)< ts I' />&nbs    ho $str  ss="default">$text&nbs    ho $strn />&nbs    ho $strifmn class="keyword">, [[os_span is="default">$text[$to?/ inpum you />&nbs    ho $str  ss="default">$text, , $text?/
&nbs    ho $str    ss="default">$text
,
$text
[< />pan class="default">$to&nbs    ho $str      /span>[$text ?/ re3e rouapuo />&nbs    ho $str      /span>, $row_rsRecordsep;/span>[[]bsp;'[[?/
&nbs    ho $str  ho $str    ss="default">$text
,
"t", ?/ number />&nbs    ho $str  ho $str      /span>[[< />pan class="default">$to, ?/ addn the dfromnsubspan toiouapuo />&nbs    ho $str        ss="default">$text ;/span>?/ ts I' />&nbs    ho $str  ho $str      /span>[[< ts I' ss="string">"t", ?/ addntoiouapuo />&nbs    ho $str        ss="default">$text&nbs    ho $str      n />&nbs    ho $str       class="keyword">, "t"[$to&nbs    ho $str    } />&nbs    ho $str  } />&nbs    ho $str  an>;
} "t"
&nbs    ho $str};/span>?/ inpum />&nbs    ss="default">$text?/ split />&nbs  ss="default">$text?/ >dm />te >
>json_dec} />&nbs >
/span>,$row_rsRecordse=div> $text $row_rsRecordse=div> $text $row_rsRecordse=div> $text ,$row_rsRecordse=div> $text $row_rsRecordse=div> $text $row_rsRecordse=div> $text ,$row_rsRecordse=div> $text $row_rsRecordse=div> $text $row_rsRecordse=div> $text &nbs >
/span>,tess="default">$text);
$to$text &nbs >
default">?* > &nbs( />&nbs    [0]nbraykebanana: a yellow, healthy fruit />&nbs    [1]nbraykespinbr : a green, healthy vegetable />&nbs    [2]nbraykesalmon: a pink, healthy fis />&nbs) />&nbs*/ />&nbs > &ndw cld;haverwas edntoiouapuo 'banana: a yellow, healthy yellowyellow />&nbs >
/span> > tloughahI w cld;sharenjust indcasean>
addna nreean>mall>>e" cla>"name">e" cla>