Last active
April 23, 2017 05:21
-
-
Save RakibSiddiquee/99de0650d6aebed7021f04014e44800b to your computer and use it in GitHub Desktop.
When we want to replace an element or some elements of an array with an element or an array of elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr = [100, 200, 300, 400, 500]; // An array containing some values | |
$new_arr = [2 => 1001]; // Take a new array with a key where we want to keep the value | |
array_splice($arr, 2, 1, $new_arr); // array_splice(old_array, position_from_where_to_start, no_of_element_of_new_array, new_array) | |
print_r($arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment