From the documentation for implode()
:
string implode ( string $glue , array $pieces )
Where:
glue
- Defaults to an empty string.pieces
- The array of strings to implode.
If you don't specify the glue
parameter in your implode()
call, an empty string will be used. In this case, you need to glue the parts with |
, so you need the following:
$newstring = implode('| ', $newstring);
echo $newstring; // => Hello | I'm john
However, I don't recommend editing values like this. Perhaps use an array instead?