0

I have a variable $users with inside an array. Dumping it I have:

array(7) {
  [0]=>
  array(6) {
    ["'ev_id'"]=>
    string(1) "1"
    ["'user_email'"]=>
    string(17) "zoom@zoom.com"
    ["'status_role'"]=>
    string(1) "0"
    ["'registration'"]=>
    string(1) "0"
    ["'confirmation'"]=>
    string(1) "0"
    ["'participation'"]=>
    string(1) "1"
  }
  [1]=>
  array(6) {
    ["'ev_id'"]=>
    string(1) "1"
    ["'user_email'"]=>
    string(24) "miao@miao.com"
    ["'status_role'"]=>
    string(1) "0"
    ["'registration'"]=>
    string(1) "0"
    ["'confirmation'"]=>
    string(1) "0"
    ["'participation'"]=>
    string(1) "1"
  }
  [2]=>
  array(6) {
    ["'ev_id'"]=>
    string(1) "1"
    ["'user_email'"]=>
    string(20) "bau@bau.com"
    ["'status_role'"]=>
    string(1) "0"
    ["'registration'"]=>
    string(1) "0"
    ["'confirmation'"]=>
    string(1) "0"
    ["'participation'"]=>
    string(1) "1"
  }
}

This is my code:

echo "<pre>";var_dump($users);
foreach ($users as $key => $value) {
echo $value['ev_id'];
}

I am becoming crazy as I want simply loop and echo the "ev_id" value in the array but I receive an error as:

Notice:  Undefined index: ev_id

The value "ev_id" exists, you can see in the dump. Why I receive an Undefined index?

Max
  • 43
  • 5
  • 2
    Why does it look like you have single quotes around that key name? How are you building that array? [That looks like that is your problem](https://3v4l.org/qtErs) – John Conde Feb 24 '21 at 01:40
  • John you are perfectly right. I have done this array by posting from a form but I added in the name of each field the quote as for example – Max Feb 24 '21 at 01:43
  • Nice to see a Happy ending :) – zergski Feb 24 '21 at 02:32

0 Answers0