TY_BCS_PHP_SLIP 25_1



Slip no. 25. Declare a multidimensional array. Display specific element from a multidimensional array. Also delete given element from the multidimensional array.
( after each operation display array contents).
PHP file :
<?php
$arr = array(array ( 1, 2, 3, 4, 5) , array ( 6, 7, 3 ) ,);
echo "before<br>";
var_dump($arr);

foreach($arr as $k1=>$q)
{
                                 foreach($q as $k2=>$r)
                                 {
                                                 if($r == 3)
                                                 {
                                                                 unset($arr[$k1][$k2]);
                                                 }
                                }
}
echo "<br><br>after:<br>";
print_r($arr);
?>

No comments:

Post a comment

Note: only a member of this blog may post a comment.