Posted By

takel on 01/08/11


Tagged

php array


Versions (?)

Array push affter


 / Published in: PHP
 

  1. function array_push_after($src,$in,$pos)
  2. {
  3. if(is_int($pos))
  4. {
  5. $R = array_merge(array_slice($src,0,$pos+1), $in, array_slice($src,$pos+1));
  6. }
  7. else
  8. {
  9. foreach($src as $k=>$v)
  10. {
  11. $R[$k]=$v;
  12. if($k==$pos)
  13. {
  14. $R=array_merge($R,$in);
  15. }
  16. }
  17. }
  18. return $R;
  19. }

Report this snippet  

You need to login to post a comment.