Aureole Posted January 18, 2008 Share Posted January 18, 2008 I don't really know how to ask for what I need but I'll try. Basically I want to turn the array $test into the value of $testing: <?php $test = '1|2|3'; $test = explode('|', $test); // $test is now an array. // I need to turn the array $test into "1", "2", "3" so I can use it in mysql IN() without doing it manually like I have. $testing = '"1", "2", "3"'; // This code doens't really matter but it may help to show you what I'm trying to do as I didn't know how to ask for the answer I need. $queryC = "SELECT `mem_id` FROM `members` WHERE `mem_id` IN({$testing}) AND `mem_online` = '1'"; $resultC = mysql_query($queryC); $friendCount = mysql_num_rows($resultC); if($friendCount == 0) { $friendText = 'My Friends'; } else { $friendText = ($friendCount == 1) ? '1 Friend Online' : $friendCount.' Friends Online'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/86593-solved-quick-array-question/ Share on other sites More sharing options...
trq Posted January 18, 2008 Share Posted January 18, 2008 Why do you need an array at all? <?php $test = '1|2|3'; $queryC = "SELECT `mem_id` FROM `members` WHERE `mem_id` IN('" . str_replace('|',',',$test) . "') AND `mem_online` = '1'"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86593-solved-quick-array-question/#findComment-442438 Share on other sites More sharing options...
Aureole Posted January 18, 2008 Author Share Posted January 18, 2008 Very clever... I didn't think of that, though I should have. You're a genius. Quote Link to comment https://forums.phpfreaks.com/topic/86593-solved-quick-array-question/#findComment-442439 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.