3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 1 => ['A' => '1', 'B' => 1, 'C' => 'TEMU3076746'], 2 => ['A' => '2', 'B' => 1.3, 'C' => 'FCIU5412720'], 3 => ['A' => '3', 'B' => 1.5, 'C' => 'TEMU3076746'], 4 => ['A' => '4', 'B' => 1.8, 'C' => 'TEMU3076746'], 5 => ['A' => '5', 'B' => 2, 'C' => 'FCIU5412720'] ]; var_export(array_column($arr, 'B', 'B')); echo "\n---\n"; var_export(array_count_values(array_column($arr, 'B'))); echo "\n---\n"; var_export(array_unique(array_column($arr, 'B')));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Implicit conversion from float 1.3 to int loses precision in /in/6ae1o on line 11 Deprecated: Implicit conversion from float 1.5 to int loses precision in /in/6ae1o on line 11 Deprecated: Implicit conversion from float 1.8 to int loses precision in /in/6ae1o on line 11 array ( 1 => 1.8, 2 => 2, ) --- Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 array ( 1 => 1, 2 => 1, ) --- array ( 0 => 1, 1 => 1.3, 2 => 1.5, 3 => 1.8, 4 => 2, )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Implicit conversion from float 1.3 to int loses precision in /in/6ae1o on line 11 Deprecated: Implicit conversion from float 1.5 to int loses precision in /in/6ae1o on line 11 Deprecated: Implicit conversion from float 1.8 to int loses precision in /in/6ae1o on line 11 array ( 1 => 1.8, 2 => 2, ) --- Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 array ( 1 => 1, 2 => 1, ) --- array ( 0 => 1, 1 => 1.3, 2 => 1.5, 3 => 1.8, 4 => 2, )
Output for 8.0.0 - 8.0.30
array ( 1 => 1.8, 2 => 2, ) --- Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 Warning: array_count_values(): Can only count string and integer values, entry skipped in /in/6ae1o on line 15 array ( 1 => 1, 2 => 1, ) --- array ( 0 => 1, 1 => 1.3, 2 => 1.5, 3 => 1.8, 4 => 2, )
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
array ( 1 => 1.8, 2 => 2, ) --- Warning: array_count_values(): Can only count STRING and INTEGER values! in /in/6ae1o on line 15 Warning: array_count_values(): Can only count STRING and INTEGER values! in /in/6ae1o on line 15 Warning: array_count_values(): Can only count STRING and INTEGER values! in /in/6ae1o on line 15 array ( 1 => 1, 2 => 1, ) --- array ( 0 => 1, 1 => 1.3, 2 => 1.5, 3 => 1.8, 4 => 2, )

preferences:
156.31 ms | 402 KiB | 156 Q