Edit: The aim of my method is to delete a value from a string in a database.
I cant seem to find the answer for this one anywhere. Can you concatenate inside a str_replace like this:
str_replace($pid . ",","",$boom);
- $pid is a page id, eg 40
- $boom is an exploded array
If i have a string: 40,56,12 i want to make it 56,12 however without the concatenator in it will produce:
,56,12
When I have the concat in the str_replace it doesnt do a thing. Is this possible?
After you have edited it becomes clear that you want to remove the value of
$pidfrom the array$boomwhich contains one number as a value. You can usearray_searchto find if it is in at if in with which key. You can thenunsetthe element from$boom:Old question:
Yes you can, see the example:
Result:
Which is pretty much like you did so you might be looking for the problem at the wrong place. You can use any string expression for the parameter.
It might be easier for you if you’re unsure to create a variable first: