splice in array php code example
Example 1: in_array php
<?php
$os = array("Apple", "Banana", "Lemon");
if (in_array("Apple", $os)) {
echo "Yeah. Exist Apple";
}
if (!in_array("Buleberry", $os)) {
echo "Oh, Don't Exist Blueberry!!!";
}
?>
Example 2: 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);
?>