3v4l.org

run code in 300+ PHP versions simultaneously
<?php $variavel = array( 0 => array( 'id' => 1, 'Nome' => 'Andre', 'Sexo' => 'Masculino', 'Dependente' => 'Fabiana', 'DependenteSexo' => 'Femenino', ), 1 => array( 'id' => 1, 'Nome' => 'Andre', 'Sexo' => 'Masculino', 'Dependente' => 'Gato', 'DependenteSexo' => 'Femenino', ), 2 => array( 'id' => 1, 'Nome' => 'Andre', 'Sexo' => 'Masculino', 'Dependente' => 'Mãe', 'DependenteSexo' => 'Femenino', ), 3 => array( 'id' => 1, 'Nome' => 'Andre', 'Sexo' => 'Masculino', 'Dependente' => 'Pai', 'DependenteSexo' => 'Masculino', ), 4 => array( 'id' => 2, 'Nome' => 'Kleber', 'Sexo' => 'Masculino', 'Dependente' => 'Thayssa', 'DependenteSexo' => 'Femenino', ), 5 => array( 'id' => 2, 'Nome' => 'Kleber', 'Sexo' => 'Masculino', 'Dependente' => 'Gato', 'DependenteSexo' => 'Femenino', ), 6 => array( 'id' => 2, 'Nome' => 'Kleber', 'Sexo' => 'Masculino', 'Dependente' => 'Mãe', 'DependenteSexo' => 'Femenino', ), 7 => array( 'id' => 2, 'Nome' => 'Kleber', 'Sexo' => 'Masculino', 'Dependente' => 'Pai', 'DependenteSexo' => 'Masculino', ), ); /** * Kleber */ $i = -1; $j = 0; $id = null; $usuarios = array(); foreach ($variavel as $v) { if ($v['id'] != $id) { $j = 0; ++$i; $id = $v['id']; $usuarios[$i]['Nome'] = $v['Nome']; $usuarios[$i]['Sexo'] = $v['Sexo']; } $usuarios[$i]['denpendetes'][$j]['Nome'] = $v['Dependente']; $usuarios[$i]['denpendetes'][$j]['Sexo'] = $v['DependenteSexo']; $j++; }
Output for git.master, git.master_jit, rfc.property-hooks

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.03 ms | 401 KiB | 8 Q