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

How do you parse and process html/xml in php?

554


What are the php functions?

554


What is namespace and use in php?

530


What is the difference between for and foreach in php?

500


how to detect a mobile device using php

592






What is the use of mysql_real_escape_string() function?

521


What is the best practice for running mysql queries in php? Consider the risk of sql injection.

558


What is the difference between $message and $$message in php?

429


What are the differences between php constants and variables?

513


What is the use of curl()?

633


How to write the form tag correctly for uploading files?

565


When to use inquire vs enquire?

536


What is session and why do we use it?

555


Do you know what is the use of rand() in php?

542


What is regex in html?

517