I have the following string:
$string = java-developer-jobs
I would like to remove -
and jobs
from $string, but I don't want to use str_replace multiple times.
I have the following string:
$string = java-developer-jobs
I would like to remove -
and jobs
from $string, but I don't want to use str_replace multiple times.
Use array as :
$toReplace = array('-','jobs');
$with = array('','');
$string = 'java-developer-jobs';
str_replace($toReplace,$with,$string);
You can use regex
for this.Try something like this:
$string = "java-developer-jobs";
$sentence = preg_replace('/\-|jobs/', ' ', $string);
echo $sentence;
Output: java developer