3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array( array('status'=>'OK','Productname'=>'test1'), array('status'=>'OK','Productname'=>'test1'), array('status'=>'OK','Productname'=>'test2'), array('status'=>'OK','Productname'=>'test2') ); $notToDuplicate = array('test2'); $newArray = array_unique($arr, SORT_REGULAR); print_r($newArray); foreach($arr as $key => &$val) { if(!in_array($val['Productname'],$arr)) { print_r(array_intersect($val, $newArray)); } }
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Array ( [0] => Array ( [status] => OK [Productname] => test1 ) [2] => Array ( [status] => OK [Productname] => test2 ) ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( )
Output for hhvm-3.10.0 - 3.12.0
Array ( [0] => Array ( [status] => OK [Productname] => test1 ) [2] => Array ( [status] => OK [Productname] => test2 ) ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( ) Notice: Array to string conversion in /in/8t4lW on line 15 Notice: Array to string conversion in /in/8t4lW on line 15 Array ( )
Output for 5.2.9 - 5.3.29
Array ( [0] => Array ( [status] => OK [Productname] => test1 ) [2] => Array ( [status] => OK [Productname] => test2 ) ) Array ( ) Array ( ) Array ( ) Array ( )
Output for 5.0.0 - 5.2.8
Warning: Wrong parameter count for array_unique() in /in/8t4lW on line 11 Warning: array_intersect(): Argument #2 is not an array in /in/8t4lW on line 15 Warning: array_intersect(): Argument #2 is not an array in /in/8t4lW on line 15 Warning: array_intersect(): Argument #2 is not an array in /in/8t4lW on line 15 Warning: array_intersect(): Argument #2 is not an array in /in/8t4lW on line 15
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/8t4lW on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/8t4lW on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/8t4lW on line 13
Process exited with code 255.