kingnutter Posted April 12, 2008 Share Posted April 12, 2008 Hi everyone, A user input page on the site I am creating has a field in which to enter comma separated tags. For searchabilty I intend to EXPLODE them into a separate table. I have been advised to check for empty elements which seems straightforward, but also check for multiple commas. Could somebody let me know the correct PHP code with which to do this? Maybe I should strip it of characters along with any other potential rogue characters? Also, should I do this BEFORE exploding the tag list into an array, or for each array element after exploding. Many thanks, Gary Quote Link to comment https://forums.phpfreaks.com/topic/100794-solved-filtering-user-input-and-explodeing/ Share on other sites More sharing options...
papaface Posted April 12, 2008 Share Posted April 12, 2008 <?php $string = "a,,b,c,,,d,e,f,g,h"; $explode = array_filter(explode(",",$string)); print_r($explode); ?> Is that what you want? Quote Link to comment https://forums.phpfreaks.com/topic/100794-solved-filtering-user-input-and-explodeing/#findComment-515524 Share on other sites More sharing options...
kingnutter Posted April 13, 2008 Author Share Posted April 13, 2008 Yes. That definitely does something. Not completely sure what or how yet though, but I'll have a play. Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/100794-solved-filtering-user-input-and-explodeing/#findComment-516296 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.