Log in

View Full Version : Resolved str_replace Help!



X96 Web Design
10-01-2009, 03:28 AM
I can't get the code below to work... I'm new to str_replace - this is my first time using it!

I'm trying to get it so special characters are removed from the value...It's messing up jQuery...


<ul>
<?php
$sql01 = mysql_query("SELECT * FROM pages");
while($menu = mysql_fetch_array($sql01)){
$themenuitem = $menu[3];
$replaceit = str_replace($fooarray, "_", $themenuitem);
$fooarray = array(":", "!", "?", "<", ">", "(", ")", "%", "$", "#", "@", "*", "&", "^", "{", "}", "[", "]", "/", "\\", "'", "\"", "+");
?>
<li><a href="?page=<?php echo $menu[3]; ?>" id="<?php echo $replaceit; ?>"><?php echo $menu[0]; ?></a></li>
<?php
}
?>
</ul>

Thanks,
X96

thetestingsite
10-01-2009, 03:39 AM
Try placing $fooarray before $replaceit.

Hope this helps.

X96 Web Design
10-01-2009, 03:41 AM
Thanks! That would do it! :p

// X96 \\