I have 10 elements of Array, how can i remove 5 array
element, with single function.

Answer Posted / sunil kumar

<?php
$a=array(1,2,3,4,75,46,17,8,9,10);
$size=count($a);
$position=4; //whose number is 75
for($i=$position;$i<$size-1;$i++)
$a[$i]=$a[$i+1]; //5th element is deleted
for($i=0;$i<$size-1;$i++) //displaying the array
echo $a[$i]."<br>";
?>


for any doubt contact sunilnagpal30@yahoo.in

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of mysql_real_escape_string() function?

520


Why is php so popular?

519


What is the method to execute a php script from the command line?

556


What is the correct syntax of mail() function in php?

570


Are php variables global?

563






What is a lambda function in php?

608


I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

487


armstrong number by using php while number is given by the keyboard.?

1701


Explain scalar type declarations in php7?

553


Is php coding easy?

507


How can we determine whether a variable is set?

529


Does php support function overloading?

568


Require_once(), require(), include(). What is difference between them?

537


What is return value in php?

520


How can you retrieve data from the mysql database using php?

547