Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. <?php
  2. $arr = [100, 200, 300, 400, 500]; // An array containing some values
  3. $new_arr = [2 => 1001]; // Take a new array with a key where we want to keep the value
  4. array_splice($arr, 2, 1, $new_arr); // array_splice(old_array, position_from_where_to_start, no_of_element_of_new_array, new_array)
  5. print_r($arr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement