php - How can I prevent str_replace from replacing twice in a row? -
i wasn't sure how word question properly, apologies.
i'm trying create clean virtual directories names in database. these names foo bar, foo/bar, foo / bar, foo: bar , on.
i'm trying replace spaces, :, / - clean urls have:
$search_array = array(" ","-", ":", "/"); $clean_url = str_replace($search_array, "-", $name); in case of foo bar, changes foo-bar desired result, when comes foo : bar changes foo---bar
is there way can str_replace replace once if multiple results found?
i thought placing things such [space]:[space] in search array have 600,000 names not sure of amount of combinations there are.
str_replace won't want here. need use preg_replace have @ documentation.
Comments
Post a Comment