Space for google add

Display specific element from a Multidimensional array. Also delete given element from the Multidimensional array in PHP .


 

Declare a Multidimensional Array. Display specific element from a Multidimensional array. Also delete given element from the Multidimensional array.


<?php

$a=array(fybcs=>array('neha'=>15,'sneha'=>45,'snehal'=>65),sybsc=>array('sonali'=>78,'rupali'=>96),tybsc=>array('ritika'=>58,'rupali'=>59));


print_r($a);

echo "<br>";

foreach($a as $pkey=>$cvalue)

{

foreach($cvalue as $kkey=>$kvalue)

{

if($kkey=='sonali')

unset($a[$pkey][$kkey]);

}

}

echo "<br>After delete an element :<br>";

print_r($a);

echo "<br>";


foreach($a as $pkey=>$cvalue)

{

foreach($cvalue as $kkey=>$kvalue)

{

if($kkey=='sneha')

unset($a[$pkey]);

}

}

echo "<br>After delete an element :<br>";

print_r($a);

echo "<br>";

?>


Post a Comment

0 Comments