Php Array Elements Slice Function

What is array_slice Function?


The "array_slice" function is used to slice 0r extract elements from the array



In the above syntax "array" specifies the array,"start" specifes where the function will start to splice, "length" specifes the total length of the slice, "preserve" if "true" else it will reset keys.

Example :

$b=array( 0 =>"Cherry",1 =>"Strawberry", 2 =>"Apple", 3 => "Orange");
Result :

Array ( [1]=> Strawberry, [2]= Apple);

In the above example the array is sliced from the first element to length of second elements length totally.

PHP Topics

Ask Questions

Ask Question