3v4l.org

run code in 300+ PHP versions simultaneously
<?php function doopScooper($dataArray, $uniqueKeys){ // store the the previously checked sub-arrays here $checked = array(); //loop through the array foreach($dataArray as $k=>$row){ // this will become the sub array that needs to be checked $checkArray = array(); //create the sub array for comparison foreach($uniqueKeys as $key) $checkArray[$key] = isset($row[$key]) ? $row[$key] : NULL; // convert sub array to string for easy comparison $checkArray = json_encode($checkArray); // check for duplicates, if found delete, else add to the checking array if(in_array($checkArray, $checked)) unset($dataArray[$k]); else $checked[] = $checkArray; } return $dataArray; } $lines = "unfinished unfinished 17876 open peters Current/17876 - unfinished unfinished 17830 new peters Current/17830 - unfinished unfinished 17810 new jongr Current/17810 -"; $lines = explode("\n",$lines); $parts=[]; foreach ($lines as $line) $parts[] = explode(' ', $line); var_dump($parts); exit; $lines = doopScooper($parts, array(7));
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(3) { [0]=> array(11) { [0]=> string(10) "unfinished" [1]=> string(10) "unfinished" [2]=> string(5) "17876" [3]=> string(5) " open" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(6) "peters" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(16) "Current/17876 - " } [1]=> array(11) { [0]=> string(10) "unfinished" [1]=> string(10) "unfinished" [2]=> string(5) "17830" [3]=> string(4) " new" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(7) " peters" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(16) "Current/17830 - " } [2]=> array(11) { [0]=> string(10) "unfinished" [1]=> string(10) "unfinished" [2]=> string(5) "17810" [3]=> string(4) " new" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(6) " jongr" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(16) " Current/17810 -" } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/uGgU4 on line 34
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/uGgU4 on line 34
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/uGgU4 on line 34
Process exited with code 255.

preferences:
316.58 ms | 401 KiB | 396 Q