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

Explain php parameterized functions.

549


What is the difference between mysql_fetch_array() and mysql_fetch_assoc()?

514


Why php is used with mysql?

522


What is in a cookie?

545


What does session start do in php?

498






Is php a dying language?

525


Explain soundex() and metaphone().

572


How is it possible to set an infinite execution time for php script?

513


Why should I learn php?

506


What is difference between Method overriding and overloading in PHP?

542


What is serialization in php?

455


What is php namespace?

537


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

560


Is ruby on rails php?

500


Explain the difference between mysql_connect and mysql_pconnect?

474