3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'sucesso' => [ 'LAUDO_VISTORIA' => [ 0 => '0027', 2 => '30027', 3 => '0027', ], 'LAUDO' => [ 0 => '0027', 2 => '30027', 3 => '0027', ], 'DADOS_DO_VEICULO' => [ 0 => '0027', 1 => '30027', ] ], 'code' => 201 ]; function r_array_unique($array) { $hasChildren = false; foreach ($array as &$item) { if (is_array($item)) { $hasChildren = true; $item = r_array_unique($item); } } return $hasChildren ? $array : array_unique($array); } var_export(r_array_unique($array));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
array ( 'sucesso' => array ( 'LAUDO_VISTORIA' => array ( 0 => '0027', 2 => '30027', ), 'LAUDO' => array ( 0 => '0027', 2 => '30027', ), 'DADOS_DO_VEICULO' => array ( 0 => '0027', 1 => '30027', ), ), 'code' => 201, )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
109.64 ms | 407 KiB | 5 Q