Reputation: 20183
i am trying to change any ' ' by a '-'
i am doing like this:
$tagname = $taginfo[1]; /* something like $tagname = 'A tag with spaces' */
$tagurl = urlencode($tagname);
$tagsize = 9 + intval($numtags)*2;
$bla = 'function("'.str_replace(' ','-',$tagname).'")';
$bla is going to be used to be attached to the onclick attribute
any idea why the result would be
onclick="function('A tag with spaces')"
instead of
onclick="function('A-tag-with-spaces')"
? may the htmlspecialchars have to do something with it?
Upvotes: 0
Views: 1500
Reputation: 25475
urlencode($tagname);
would turn your white spaces into %20
so your string would then be
A%20tag%20with%20spaces
You could either replace %20
with -
or do the replace before the encoding.
Upvotes: 2