Home Tutorial Php Phpbasics PHP Array_search functions

 
 

PHP Array_search functions
Posted on: October 27, 2009 at 12:00 AM
There are more then hundreds of PHP Array Search functions available in the PHP, which can be used differently according to the programming needs.

Learn PHP Array_search functions

There are more then hundreds of functions available in the PHP, which can be used differently according to the programming needs. If we categories them then we can say that they are five or six type such …built-in functions, variable functions, anonymous functions, array functions etc…

In this post I am discussing about the “array_search” function, which is part of “array functions” available in the PHP. 

In general array_search function searches array, for the given condition (value) and returns key if the condition is true. For example if you are looking for the name of an employee who has the employee ID 6872. How will you do that?

Let’s take a small example in the PHP …

<?php
$array = array(6678 => 'Nick', 3389 => 'Ujjwal', 6872 => 'Jyotsna', 86987 => 'EShan');

$key = array_search('6872', $array);
$key = array_search('6678', $array);  
?>
In the given code you can see that we have created an array type variable, which has assigned both key and value.

Related Tags for PHP Array_search functions:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.