my function doesn't work correctly and create extra array

Viewed 33

I have this function that return wrong value.

function kral_bstock_notif_submit() {

    $productid = $_POST['productids'];
    $customeremail = $_POST['customeremails'];

    $notif_list_temp = get_post_meta($productid, '_kral_notif_list', false);

    if (count($notif_list_temp) == 1 || $notif_list_temp[0] == '') {
        $notif_list_temp[0] = $customeremail;
    } else {
        $find_cell = count($notif_list_temp) + 1;
        $notif_list_temp[$find_cell] = $customeremail;
    }

    update_post_meta($productid, '_kral_notif_list',  $notif_list_temp);
}

I want this function to return me a single array like this :

array(1) {
  [0]=>
  string(23) "ah.yaldoughie@gmail.com"
}

But it return an array in array in array like like this :

array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(23) "ah.yaldoughie@gmail.com"
  }
}

I want this function to add one email to previous array and save it again

0 Answers
Related