Forum Moderators: coopster
from this;
$in = '10. Prom Night (2008) - $1.0M';
to this;
$out = 'Prom+Night+(2008)';
the number in the begining may varry from 1 to 100 but it's always limited by a dot (.)
the data at the end (- $1.0M) may varry like; (- $100.990M) but it always begin with (-)
the result as you can see, should not contain spaces, but, plus signs replacing spaces.
thank you in advance for providing a regular expression handling this .
Try this:
function stripChars($str)
{
$str = preg_replace('/^[0-9]+\. /','',$str);
$str = preg_replace('/ -+.+/','',$str);
return $str;
}$out = stripChars('10. Prom Night (2008) - $1.0M');
// you can either urlencode the result but that will replace the () characters
// as well, if you just want to replace the spaces with the + character,
// use str_replace(' ','+',$out);
print $out;