I get "Undefined offset" errors, starting from index 20 as shown in the following output:
<b>Notice</b>: Undefined offset: 20 in <b>/var/www/sso/html/wp-content/plugins/auto-login/papex-auto-login.php</b> on line <b>214</b><br />
<br />
<b>Notice</b>: Undefined offset: 21 in <b>/var/www/sso/html/wp-content/plugins/auto-login/papex-auto-login.php</b> on line <b>214</b><br />
<br />
<b>Notice</b>: Undefined offset: 22 in <b>/var/www/sso/html/wp-content/plugins/auto-login/papex-auto-login.php</b> on line <b>214</b><br />
<br />
My array $match - below - has 20 indexes. The output from my SQL question is correct – I have checked it multiple times. With print_r, the output from the foreach loop is echo $value->meta_key.
It seems that the while loop goes through the whole $match array, but won't terminate. Thats why I think it starts producing the "Undefined" offsets, starting from 20.
What am I doing wrong; how come – if its right – that the code doesn't exit the while loop?
// Get user id
$db_user_id = $wpdb->get_row("SELECT ID FROM $table_users WHERE user_email = '$user_email'");
// Get user result
$results = $wpdb->get_results("SELECT * FROM $table_usermeta WHERE user_id = '$db_user_id->ID'");
$match = array(
"billing_country",
"billing_first_name",
"billing_last_name",
"billing_company",
"billing_address_1",
"billing_address_2",
"billing_city",
"billing_state",
"billing_postcode",
"billing_email",
"billing_phone",
"shipping_country",
"shipping_first_name",
"shipping_last_name",
"shipping_company",
"shipping_address_1",
"shipping_address_2",
"shipping_city",
"shipping_state",
"shipping_postcode"
);
foreach($results as $value)
{
$check = TRUE;
$i = 0;
while($check == TRUE)
{
if($match[$i] == $value->meta_key)
{
echo $i . ' ';
echo ' inne ';
$check = FALSE;
break;
}
$i++;
}
}