Home > Software design >  Access array in array elements
Access array in array elements

Time:10-09

I have an array named 'users' in which I am storing some variables as you see below.I want to verify if the 'nume' (name) value already existing in this array is the same as the value introduced by a person in a search box. I've tried some methods but I haven't obtained the wanted result. I think it is something obvious I can't see at the moment.

EDIT : The image is the result of var_dump() of my code. I am using it for people to understand what I want to know.

Here is the image

CodePudding user response:

it's simple, try that:

$searchValue = 'victor';
$index = array_search($searchValue, array_column($users, 'nume'));
  •  Tags:  
  • php
  • Related