MySQL Forums
Forum List  »  PHP

Posted by: Linda Cesia Salazar
Date: October 08, 2009 03:09PM

I have this list in mysql (,1,3,7,8,)

I can receive that list with $result[users]

To delete the first and last coma, I did the next code:

$str = "$result[users]";
$str = trim($str,",");

It returns: (1, 3, 7, 8) ...which is good....

Now, I want to compare if my value $id_user which is equal to 3 exist within my list.

$someValue = $id_user;
$arr = array($str);

if(in_array($someValue, $arr)) {
echo "exist";
} else {
echo "no exist";

It is not working :( if I try the next, it works:

$someValue = $id_user;
$arr = array(1,3, 7, 8);

But, when I try to use the result from my mysql db, it doesn't work. Could any body help me??

Options: ReplyQuote

Written By
October 08, 2009 03:09PM
October 08, 2009 07:19PM
October 12, 2009 12:16AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.