My array is

$arr = array(
	'global' => array(
		array('tabs', 'tabs', 'tabs', array(
			'Main' => 'main',
			'Gallery' => 'galleryID',
			'mera' => 'mera',
		)),

	array('main','div',  'div'),
	array('egice', 'Eice', 'text', '', ''),
	array('closeHere', 'closeHere', 'closeHere'),


	array('galleryID','div',  'div'),
	array('gallery', 'Gallery #1', 'image', '', ''),
	array('closeHere', 'closeHere', 'closeHere'),


	array('networking', 'div', 'div'),
	array('siLype', 'SiLype', 'text', '', ''),
	array('gpXCge', 'GpXCge',  'toggle_button', '1', 'Yes', 'No', ''),
	array('closeHere', 'closeHere', 'closeHere'),


	array('mera', 'div', 'div'),
	array('maimera', 'Maimera', 'repeatedText', 'resYI', 'GYL',''),
	array('closeHere', 'closeHere', 'closeHere'),



	array( 'moures','div', 'div'),
	array('meLmo', 'MeLmo', 'text', '', ''),
	array('cYSlot', 'CYSlot', 'text', '', ''),
	array('closeHere', 'closeHere', 'closeHere'),

	array('clT', 'clT', 'clT'),



),

);

Simply, I want to split the main array to multiple arrays
extract new Array if “div” value found

I had tried here to do it but I can’t
https://3v4l.org/ppj1O 1
Could you help?

    Added [code]...[/code] tags around your code block. Please be sure to use them where applicable in future posts. 🙂

      Is something like this what you're after?

      $split = [];
      foreach($arr as $key => $data) {
        $i = 0;
        foreach($data as $subArray) {
          if(in_array('div', $subArray)) {
            $i++;
          }
          $split[$key][$i][] = $subArray;
        }
      }
      print_r($split);
      
        Write a Reply...