php,nginx,laravel-5,hhvm,array-intersect
This looks like a bug in HHVM. I took the liberty of filing an issue for you: https://github.com/facebook/hhvm/issues/5585 You can follow along there for more updates.
You can do this with call_user_func_array: $result = call_user_func_array("array_intersect", $a); ...
$result = array(); foreach( $array1 as $index ) { $result[] = $array2[ $index ]; } echo implode( ', ', $result ); ...
This is because you put all values to lowercase. Just change to array_uintersect() and use strcasecmp() as callback function to compare them case-insensitive, like this: $result = array_uintersect($array1, $array2, "strcasecmp"); output: Array ( [a] => Green [0] => Red ) ...
It is normal, because it is just comparing if it is the same type of object. You have two options : Change the parameters you are using by comparing string instead of simpleXMLElement with the array_intersect function. Not recommended, because you are not comparing the actual values of each xml...
array_intersect() is not recursive, it sees the inner arrays as just an array. You would need to use something like this: function array_intersect_recursive() { foreach(func_get_args() as $arg) { $args[] = array_map('serialize', $arg); } $result = call_user_func_array('array_intersect', $args); return array_map('unserialize', $result); } $result = array_intersect_recursive($aArray, $jump); ...
php,arrays,array-unique,array-map,array-intersect
<?php $data = array( array( 'time' => '17:16', 'city' => 'Bristol', 'amount' => 373, ), array( 'time' => '18:16', 'city' => 'Bristol', 'amount' => 373, ), array( 'time' => '18:16', 'city' => 'Wednesbury', 'amount' => 699, ), array( 'time' => '19:16', 'city' => 'Wednesbury', 'amount' => 699, ), ); $tmp...
php,arrays,multidimensional-array,compare,array-intersect
You are looking for the array_key_exists() function of PHP. foreach ($inventoryStock as $key => $value) { if (array_key_exists($key, $posStock)) { $posStock[$key] = $value; continue; // Continue Loop } // Do something if the array key doesn't exist. } To expand on why I would do it this way. I now...
javascript,arrays,intersection,array-intersect
You need to add the indices to your result; function intersect(first, second) { var temp = []; for(var i = 0; i < first.length; i++){ for(var k = 0; k < second.length; k++){ if(first[i] == second[k]){ temp.push([i, k]); // push i and k as an array } } } return...