3v4l.org

run code in 300+ PHP versions simultaneously
<?php $resultArray = [ [ 'nid' => [ [ 'value' => 1, ] ], 'vid' => [ [ 'value' => 2, ] ], 'cid' => [ [ 'value' => 3, ] ], 'field' => [ [ 'target_id' => 4, ] ], ], [ 'nid' => [ [ 'value' => 11, ] ], 'vid' => [ [ 'value' => 22, ] ], 'cid' => [ [ 'value' => 33, ] ], 'field' => [ [ 'target_id' => 44, ] ], ], ]; $test = 1; foreach ($resultArray as $items) { // Echo the current test number echo "Test{$test} = "; $values = []; foreach ($items as $item) { // Get the correct value. if (array_key_exists('value', $item[0])) { $values[] = $item[0]['value']; continue; } if (array_key_exists('target_id', $item[0])) { $values[] = $item[0]['target_id']; continue; } } echo '"' . implode('", "', $values) . '"' . "\n"; $test++; }

Abusive script

This script was stopped while abusing our resources

Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.27, 7.2.3 - 7.2.34, 7.3.0 - 7.3.29, 7.4.0 - 7.4.22, 8.0.0 - 8.0.8, 8.1.25 - 8.1.29, 8.2.12 - 8.2.23, 8.3.0 - 8.3.11
Test1 = "1", "2", "3", "4" Test2 = "11", "22", "33", "44"
Output for 7.1.28 - 7.1.33, 7.2.0 - 7.2.2

Process exited with code 137.

preferences:
108.61 ms | 407 KiB | 5 Q