Main Links
Not logged in
Your Account
Home/Tutorials/Find Value in Array
a year ago
Find Value in Array
Content by: Steve Stewart
Posted a year ago with 800 views
A term used for looking in arrays too see if value exists. First we'll create an array. Then the needle (Word) we want to find. An we'll use php array_search.
<?php $haystack = array('audi', 'bmw', 'ford', 'saab', 'vauxhaul'); $needle = 'saab'; $index = array_search($needle, $haystack); if(!array_search($needle, $haystack)){ echo 'We did not find '.$needle.''; } else { echo $needle.' was found'; }
Content by: Steve Stewart
Posted a year ago with 800 views
Find Needle in Haystack
A term used for looking in arrays too see if value exists.
First we'll create an array.
Then the needle (Word) we want to find.
An we'll use php array_search.