Page 1 of 1

Why doesnt this work

Posted: Fri Apr 22, 2016 3:05 am
by hybris

Code: Select all

<?php
$test=array('A','B','C','D','E','F');
$key=array('A','C');
print_r($test);
echo"<br>";
$temp = array_diff( [$test], [$key] );
$a = implode("|", $temp);
echo $a;
?>
If in $a = implode I set the array to $test it works and print A|B|C....
If i set it to $temp it doesnt work although I thought array_diff should return an array ($test where the values in $key are removed).

Why is this not working?

Thanks

Re: Why doesnt this work

Posted: Fri Apr 22, 2016 6:07 am
by Celauran
What steps have you taken to debug this? Have you determined where it's failing?

Re: Why doesnt this work

Posted: Fri Apr 22, 2016 8:33 am
by Christopher
?

Code: Select all

$temp = array_diff( [$test], [$key] );