Search This Blog

delete array elements with unset() in php

<?php

$num=array(1,2,3,4,5,6,7,8,9,10);
echo '<b>array before delete elements :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}
echo '<br><br>';

//delete array element

unset($num[3]);
unset($num[0],$num[1],$num[2]);
echo '<b>array after delete elements (1,2,3,4) :</b>';
foreach($num as $num1)
{
echo ' '.$num1;
}


?>

output :

array before delete elements : 1 2 3 4 5 6 7 8 9 10

array after delete elements (1,2,3,4) : 5 6 7 8 9 10

Share Links

Related Posts Plugin for WordPress, Blogger...