Re: [PHP] Newbie Question: Array Comparison ---
David Robley [EMAIL PROTECTED] wrote: in_array might be one tool - loop through $Foo and print $Foo[n] if it's not in the array $donotprint [cut] And doubtless there are other, better ways. Offers, anyone? Look at array_diff http://download.php.net/manual/en/function.array-diff.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Newbie Question: Array Comparison ---
This is a simple question, but I'm having trouble figuring out a solution. Let's say I have 2 arrays: $DoNotPrint=array(a,b,c); $Foo=array(c,d,e): What is the best way to print every value in $Foo that does NOT match a value in $DoNotPrint? For instance, in this example, c should not be print. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie Question: Array Comparison ---
On Thu, 20 Sep 2001 14:07, Jeremy Moles wrote: This is a simple question, but I'm having trouble figuring out a solution. Let's say I have 2 arrays: $DoNotPrint=array(a,b,c); $Foo=array(c,d,e): What is the best way to print every value in $Foo that does NOT match a value in $DoNotPrint? For instance, in this example, c should not be print. in_array might be one tool - loop through $Foo and print $Foo[n] if it's not in the array $donotprint -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA A cat is always on the wrong side of a door. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie Question: Array Comparison ---
I don't quite understand what you're saying. I'm really sorry. Could you show me some code? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie Question: Array Comparison ---
On Thu, 20 Sep 2001 14:30, Jeremy Moles wrote: I don't quite understand what you're saying. I'm really sorry. Could you show me some code? Original problem: This is a simple question, but I'm having trouble figuring out a solution. Let's say I have 2 arrays: $DoNotPrint=array(a,b,c); $Foo=array(c,d,e): What is the best way to print every value in $Foo that does NOT match a value in $DoNotPrint? For instance, in this example, c should not be print. in_array might be one tool - loop through $Foo and print $Foo[n] if it's not in the array $donotprint foreach($Foo as $val) { if(!in_array($val,$DoNotPrint) { echo $val; } } Any syntax errors you find in that you can keep :-) And doubtless there are other, better ways. Offers, anyone? -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Food is an important part of a balanced diet. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]