3v4l.org

run code in 200+ PHP versions simultaneously
<?php $arr = array( 'global' => array( /* TABS */ 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'), ), ); $split = []; $i = 0; foreach($arr as $k => $v) { if ($v == 'div') { $i++; } $split[$i][$k] = $v; } echo '<pre>'; print_r($split); echo '</pre>';
based on vdIas
Output for 7.2.0 - 7.4.6
<pre>Array ( [0] => Array ( [global] => Array ( [0] => Array ( [0] => tabs [1] => tabs [2] => tabs [3] => Array ( [Main] => main [Gallery] => galleryID [mera] => mera ) ) [1] => Array ( [0] => main [1] => div [2] => div ) [2] => Array ( [0] => egice [1] => Eice [2] => text [3] => [4] => ) [3] => Array ( [0] => closeHere [1] => closeHere [2] => closeHere ) [4] => Array ( [0] => galleryID [1] => div [2] => div ) [5] => Array ( [0] => gallery [1] => Gallery #1 [2] => image [3] => [4] => ) [6] => Array ( [0] => closeHere [1] => closeHere [2] => closeHere ) [7] => Array ( [0] => networking [1] => div [2] => div ) [8] => Array ( [0] => siLype [1] => SiLype [2] => text [3] => [4] => ) [9] => Array ( [0] => gpXCge [1] => GpXCge [2] => toggle_button [3] => 1 [4] => Yes [5] => No [6] => ) [10] => Array ( [0] => closeHere [1] => closeHere [2] => closeHere ) [11] => Array ( [0] => mera [1] => div [2] => div ) [12] => Array ( [0] => maimera [1] => Maimera [2] => repeatedText [3] => resYI [4] => GYL [5] => ) [13] => Array ( [0] => closeHere [1] => closeHere [2] => closeHere ) [14] => Array ( [0] => moures [1] => div [2] => div ) [15] => Array ( [0] => meLmo [1] => MeLmo [2] => text [3] => [4] => ) [16] => Array ( [0] => cYSlot [1] => CYSlot [2] => text [3] => [4] => ) [17] => Array ( [0] => closeHere [1] => closeHere [2] => closeHere ) [18] => Array ( [0] => clT [1] => clT [2] => clT ) ) ) ) </pre>