Why doesnt this work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Why doesnt this work

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why doesnt this work

Post by Celauran »

What steps have you taken to debug this? Have you determined where it's failing?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Why doesnt this work

Post by Christopher »

?

Code: Select all

$temp = array_diff( [$test], [$key] );
(#10850)
Post Reply