Site icon DataFlair

PHP array_slice() Function

Program 1

<html>
<body>
    <center>
<pre>
     
<?php

 //                 -6           -5         -4          -3           -2              -1
//    $myArrray=["Indore","Pune","Delhi","Mumbai","Raipur","Banglore"];
//       //                  0           1          2         3             4             5
// //$newArray=array_slice($myArrray,1,3,true);
//   //$newArray=array_slice($myArrray,-3,2,true);
//   $newArray=array_slice($myArrray,-4,3,true);
// print_r($newArray);
//  $myArray=[101=>"Indore",102=>"Pune",103=>"Delhi",104=>"Mumbai",105=>"Raipur"];
//  $newArray=array_slice($myArray,2,3,true);

// print_r($newArray);

?>
</pre>
</center>
</body>
</html>

 

Exit mobile version