Check if the element is in PHP array. Code example open

Check if the element is in PHP array. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

Let’s create a test array:

[php]
$users = [
  "name" => 'Spike',
  "surname" => 'Johnson',
  "age" => 23
];

To check whether the element is in the array, use the in_array function:

in_array('Spike', $users);//check if Spike is in the $user array;
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation