Jump to content

Recommended Posts

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';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/86593-solved-quick-array-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.