Yes, this is a bit of a tricky question; one (without copies), unlike any odd array. Let me explain, so start here;
$a = array ( 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6 ) ;
Imagine that this array is long, more than a hundred long. I go through it, step by step, but at some point (let it all be that this happens in the second paragraph), something happens. Maybe the data is scared. However, we need to add some elements to it for further processing, and then continue the cycle without losing the current position. Basically, I would like to do something like this:
echo current ( $a ) ; // 'two'
array_insert ( $a, 'four', 'new_item', 100 ) ;
echo current ( $a ) ; // 'two'
Definition for array_insert ($ array, $ key_where_insert_happens, $ new_key, $ new_value); Of course, $ new_key and $ new_value should be wrapped in an array wrapper, but that's besides the dot right now. Here, what I want to see happens after the above code has been run;
print_r ( $a ) ; // array ( 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'new_item' => 100, 'five' => 5, 'six' => 6 ) ;
echo current ( $a ) ; // 'two'
Whenever you use array_splice, array_slice, array_push or most of the other fiddling functions of the array, you basically create a copy of the array and then you can copy it, but that breaks the reference to the original array and position like well and my loop is above the breaks. I could use a direct link (i.e. $a['new_item'] = 'whatever;) or put it at the end, but none of them would insert elements at a given position.
? ( )? :
- (
current()) - / (array_slice)
- ($ old = $new)
- ( reset(), , [!!!!!!])
, -, kludgy, ? array_set_position ($ key), , _, ( )?