I am attempting to check to see if a variable is in an array, and if it is echo
true if it is not echo
false. Not sure what the issue is, but the code below will kick out both
true and
false for some of the
true variables. Please let me know if you need anymore information. Any and all help is appreciated!
- Code: Select all
<?php
$page = $_GET['image_id'];
if (!empty($_SESSION)){
foreach($_SESSION as $name => $value2) {
if (substr($name, 0, 7)=='images_') {
$id = substr($name, 7, (strlen($name)-7));
$get = mysql_query('SELECT * FROM images WHERE image_id='.mysql_real_escape_string((int)$id));
while ($cart_info_row = mysql_fetch_assoc($get)) {
$cart = array('image_id' => $cart_info_row['image_id'],);
$array = array_values($cart);
print_r ($array);
if (in_array($page, $array) == TRUE) { echo 'true';}
}
}
}if (in_array($page, $array) ==FALSE){
echo 'false';}
} else echo false;
} ?>