36 of 110 menu

PHP Check Element in Array

To check an element in an array, you can use the in_array function.

Let the following array be given:

<?php $arr = ['a', 'b', 'c']; ?>

Let's check using in_array if the element 'b' is in this array:

<?php $arr = ['a', 'b', 'c']; $elem = in_array('b', $arr); var_dump($elem); ?>

Code execution result:

true
English
БеларускаяEspañolРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline