how to i replace
Apple 123456
to
Apple 1|Apple 2|Apple 3|Apple 4|Apple 5|Apple 6
by php pcre?
With this one you get partially what you want:
That results in: Apple Apple 1|Apple 2|Apple 3|Apple 4|Apple 5|Apple 6|
For removing the first "Apple" you could str_replace()
or explode()
the initial string, resulting something like
The result here is Apple 1|Apple 2|Apple 3|Apple 4|Apple 5|Apple 6|
.
You can remove the last pipe by using substr($result, 0, -1)
.
The final code will look like this: