Currently I have this code which replaces any double space with a .
It works as expected:
-
The order of the array does matter otherwise you will get
instead of
so try:
str_replace(array(' ','||'), array('|','
'), trim($result['garment_type'] ));
Something like this:
echo str_replace(array(' ','||'), array('|','
'), 'crunchy bugs are so tasty man');
Gives you:
crunchy
bugs|are|so
|tasty|man
Basically you are changing each space first to | then you are changing any that have two beside each other (||) to
.
If you go the other way, you will change two spaces to
and then you are changing single spaces to | and inbetween the
there is a space, so you end up with
.
EDIT with your code:
'
Garments:
' . str_replace(array(' ','||'), array('|','
'), trim($result['garment_type'] )) . '
'
- 热议问题