I have this array, generated from a database:
do {
$rsvp_array[$row_rsRSVP['rsv_guest']] = array(
'id' => $row_rsRSVP['rsv_id'],
'guest' => $row_rsRSVP['rsv_guest'],
'confirmed' => $row_rsRSVP['rsv_confirmed']
);
} while ($row_rsRSVP = mysql_fetch_assoc($rsRSVP));
It's vey fine, with print_r() I get this:
Array
(
[1] => Array
(
[id] => 1
[guest] => 1
[confirmed] => 1
)
[15] => Array
(
[id] => 2
[guest] => 15
[confirmed] => 0
)
[5] => Array
(
[id] => 3
[guest] => 5
[confirmed] => 1
)
[10] => Array
(
[id] => 4
[guest] => 10
[confirmed] => 1
)
[6] => Array
(
[id] => 5
[guest] => 6
[confirmed] => 0
)
)
So I know that the array is working.
Now I need to see if a number is in the main array, i.e.:
if (in_array(15, $rsvp_array)) { echo 'OK'; }
And well, this doesn't work! Number 15 is the second key of the array, but no luck! Where am I wrong? Thanks in advance for the answers...
do{}while()
is not suitable for fetching data, always usewhile(){}
– zerkms Apr 13 '11 at 10:31