Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement