Php Array Get Key By Value

PHP 8 , PHP

Nicesnippets

821

04-06-2021


Php Array Get Key By Value

Hi guys,

Today i will explained to the search php array key by value through. This example is so easy to use in php. THis example to array_search() function to use.

Array_search() function is provides to the php. This function is used to array value through return the value key in php.

So let's start to the example and follow to the my all step.

Solution


array_search("laravel",$language);

Example :

This exampel to i will used to 4 key & value array create.

<?php

$language=array("a"=>"laravel", "b"=>"php", "c"=>"java", "d"=>"odo");

echo array_search("php",$language);

?>

Output :

b

So, finally we are done with our code we can get below output.


Recommended Posts