Below is Simple Example which shows how the array keys or array values can be obtained from a array.
<?php
$personinfo=array(array("name"=>"john","address"=>"pune","age"=>30),
array("name"=>"Sathya","address"=>"Nashik","age"=>39),
array("name"=>"madhav","address"=>"pune","age"=>22));
$arr1=array_keys($personinfo);
$arr2=array_values($personinfo);
echo "OUTPUT AS ONLY KEYS FOR GIVEN ARRAY";
echo "<br><br>";
print_r($arr1);
echo "<br><br>";
echo "OUTPUT AS ONLY VALUES FOR GIVEN ARRAY";
echo "<br><br>";
print_r($arr2);
?>
<?php
$personinfo=array(array("name"=>"john","address"=>"pune","age"=>30),
array("name"=>"Sathya","address"=>"Nashik","age"=>39),
array("name"=>"madhav","address"=>"pune","age"=>22));
$arr1=array_keys($personinfo);
$arr2=array_values($personinfo);
echo "OUTPUT AS ONLY KEYS FOR GIVEN ARRAY";
echo "<br><br>";
print_r($arr1);
echo "<br><br>";
echo "OUTPUT AS ONLY VALUES FOR GIVEN ARRAY";
echo "<br><br>";
print_r($arr2);
?>
No comments:
Post a Comment