limit offset array php
array_slice($array, 0, 50); // same as offset 0 limit 50 in sql
limit offset array php
array_slice($array, 0, 50); // same as offset 0 limit 50 in sql
array splice php
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
var_dump($input);
?>
slice array php
array_slice() function is used to get selected part of an array.
Syntax:
array_slice(array, start, length, preserve)
*preserve = false (default)
If we put preserve=true then the key of value are same as original array.
Example (without preserve):
<?php
$a=array("red","green","blue","yellow","brown");
print_r(array_slice($a,1,2));
?>
Output:
Array ( [0] => green [1] => blue )
Example (with preserve):
<?php
$a=array("red","green","blue","yellow","brown");
print_r(array_slice($a,1,2,true));
?>
Output:
Array ( [1] => green [2] => blue )
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us