n3mesis125 Posted June 9, 2008 Share Posted June 9, 2008 Hey folks, this may be a dumb question but is it possible to use /'s in multidimensional arrays? ie: <?php $subArray .= "{'Name':'" .$name. "','Tag':'" .$row['cat_tag']. "','Children':'" .$row['cat_children']. "','Exclude':'" .$row['cat_exclude']. "','Field':'" .$row['cat_field']. "'}" .$sa_end; ?> if $name has a value in it that is say H/R Express when i print $subArray into javascript such as var test = "[<? print $subArray; ?>]"; it messes up in javascript because of the /'s in $name. Is there some way I can escape $name or make it so that the /'s don't mess up. Thanks, n3m. Link to comment https://forums.phpfreaks.com/topic/109480-how-to-escape-or-make-work-in-multidimensional-array/ Share on other sites More sharing options...
kenrbnsn Posted June 9, 2008 Share Posted June 9, 2008 Forward slashes "/" should be handled just fine. It's backslashes "\" that usually cause problems. Please show us more of your code. Ken Link to comment https://forums.phpfreaks.com/topic/109480-how-to-escape-or-make-work-in-multidimensional-array/#findComment-561592 Share on other sites More sharing options...
n3mesis125 Posted June 9, 2008 Author Share Posted June 9, 2008 Oh nvm, i located the problem, it was an apostrophe ' that was doing it, is there a way to escape these so they work? I had a word like, Traveler's Ticket and it started spitting out javascript errors Link to comment https://forums.phpfreaks.com/topic/109480-how-to-escape-or-make-work-in-multidimensional-array/#findComment-561597 Share on other sites More sharing options...
kenrbnsn Posted June 9, 2008 Share Posted June 9, 2008 You can use the addslashes() function to escape the single quotes. Ken Link to comment https://forums.phpfreaks.com/topic/109480-how-to-escape-or-make-work-in-multidimensional-array/#findComment-561599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.