Jump to content

[SOLVED] Quick array question


Aureole

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.