-3

I have this code in PHP with that uses the function, strstr():

$conversation = strstr($bash, '_');
$pseudo = strrchr($bash, '_');
//On ajoute les balises html au pseudo et a la conversation
$cherche = array($pseudo, $conversation);
$remplace = array("'<span class=\"pseudo\">' , $pseudo , '</span>'",
                  "'<span class=\"pseudo\">' , $conversation , '</span><br />'");
str_replace($cherche, $remplace , $bash);
echo $bash;

However, echo function display $bash does not display any error message.

Panda
  • 6,955
  • 6
  • 40
  • 55
  • Use `echo` and `print_r` throughout and figure out which step isn't producing what you think it should be. Basic debugging. We can't debug this without knowing what `$bash` contains, anyways. – ceejayoz Jun 27 '14 at 16:14
  • i think it might be your str_replace – Marc Jun 27 '14 at 16:17

1 Answers1

1

str_replace() RETURNS the modified string, it does not do an in-place change.

$new_bash = str_replace($cherche, $remplace, $bash);
Marc B
  • 356,200
  • 43
  • 426
  • 500