![]() |
exclusive value in array [php]
I'm fucking with this script and i need toi get this simple thing done.
a. array(100,200,400); b. array(100); c. array(200); 100 is my goal here. I need to know what array has ONLY 100 in there (b.). Any kids drinking at home tonight? |
probably a better way to do it then i did it...and i didnt test it
Code:
fuction chkArr($array) { |
yea you can you in_array() in place of some of my code above
|
This should have you on your way :)
Code:
$array = array(array(100,200,400), array(100), array(200)); |
Nope, i have that
if (in_array(200,$p2osArr)){print "okay ja -> ";} But this does not ISOLATE 100, it just looks if it there. |
@Varius: I'll check that. At first glance, what if the array has 2x100. Like this:
$a = array(100,200,100,400); |
Quote:
|
Oh, and there's one array, i should have written this:
$a = array(100,200,400); $a = array(100,200,100,400); $a = array(100); $a = array(200); |
Quote:
so the array only has 200 in it. |
Quote:
|
i'm a genius, i'm on to something ...
|
Varius got it right. It doesn't fail on multiple 100's. You are asking if it has only one value and if that value is 100. That is what he is checking for.
His first condition checks for value of 100. His second condition checks if there is more than one value. Done. |
THIS does exactly what i want:
Code:
$a = array(100,100,100); |
Even better, now when they have 4+ items, they have to get parcelpackaging anyhow;-)
*pads self on the back PHP Code:
|
All times are GMT -7. The time now is 07:12 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123