Warning: file_put_contents(sites/nerkn/cache/containers/queryList/select_s_from_pages_where_pageTypeproject1.file.php): failed to open stream: No such file or directory in /home/erkintek/nerkl/inc/classBasic.php on line 247

Warning: file_put_contents(sites/nerkn/cache/containers/queryList/select_s_from_pages_where_pageTypeproject1.file.php): failed to open stream: No such file or directory in /home/erkintek/nerkl/inc/classBasic.php on line 247

Warning: file_put_contents(sites/nerkn/cache/containers/queryList/select_s_from_pages_where_pageTypeknowlagebase1.file.php): failed to open stream: No such file or directory in /home/erkintek/nerkl/inc/classBasic.php on line 247

Warning: Cannot modify header information - headers already sent by (output started at /home/erkintek/nerkl/inc/classBasic.php:247) in /home/erkintek/nerkl/inc/layout.php on line 227
array_insert

Nerkn

Php developer, drupal, html, css, jquery, ajax, javascript
s:147:"

array_insert

I never needed that funciton, but van be useful: You need to insert elements inside a array:


/**
* Inserts values from $arr2 after (or before) $key in $arr1  if $key is not found, $arr2 is appended to $arr1 using array_merge()
*
* @param $arr1 array to insert into
* @param $key key of $arr1 to insert after
* @param $arr2  array whose values should be inserted
* @param $before  insert before the given key. defaults to inserting after
* @return  merged array
*/
function array_insert($arr1$key$arr2$before FALSE){
  
$done FALSE;
  foreach(
$arr1 as $arr1_key => $arr1_val){
    if(!
$before){
      
$new_array[$arr1_key] = $arr1_val;
    }
    if(
$arr1_key == $key && !$done){
      foreach(
$arr2 as $arr2_key => $arr2_val){
        
$new_array[$arr2_key] = $arr2_val;
      }
      
$done TRUE;
    }
    if(
$before){
      
$new_array[$arr1_key] = $arr1_val;
    }
  }
  if(!
$done){
    
$new_array array_merge($arr1$arr2);
  }
  return 
$new_array;
}
";