⊗ppPmAFSch 163 of 447 menu

Searching in Arrays in PHP

in_array array_search

Given an array:

<?php $arr = [1, 2, 3, 4, 5]; ?>

Check that it contains an element with the value 3.

Given an array:

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

Find the position of the first element '-'.

Given an array:

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

Find the position of the first element '-' and remove it using the array_splice function.

byenru