[Solved] Removing array of arrays for certain inner values in PHP


You can do it like below:-

foreach($array as $key=>$value){
  if(is_array($value) && count($value) ==1){
    $array[$key] = $value[0];
  }
}

Output:- https://eval.in/912263

Or you can use Passing by Reference mechanism also:-

foreach($array as &$value){
  if(is_array($value) && count($value) ==1){
    $value = $value[0];
  }
}

Output:- https://eval.in/912264

Reference:- Passing by Reference

0

solved Removing array of arrays for certain inner values in PHP