what is array_search() in php?

Answer Posted / binu.v.pillai

It will search a particular value in an array and if it
find that , it will return corresponding index

<?php
$fruitArray = array(0 => 'orange', 1 => 'apple', 2
=> 'mango', 3 => 'grapes');

$key = array_search('apple', $fruitArray); // $key = 1;
$key = array_search('orange', $fruitArray); // $key = 0;
?>

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the difference between accessing a class method via -> and via ::?

529


Tell me how do you define a constant?

521


How to delete file in php?

522


How to generate a form?

611


How to randomly retrieve a value from an array?

550






How the result set of mysql be handled in php?

594


What is php call function?

496


What is the difference between null and empty?

573


What are the environmental variables?

582


How many types of php are there?

518


What is the tags in PHP is not a valid way to begin and end a PHP code block?

787


Explain the purpose of output buffering in php.

508


How to find length of an array in php ?

554


What is smarty?

499


How to take a substring from a given string in php?

514