![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
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?
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Apr 2002
Location: Houston
Posts: 5,651
|
probably a better way to do it then i did it...and i didnt test it
Code:
fuction chkArr($array) { foreach($array as $k=>$v) { if($v!=100) { return False; } else { $didfind=True; } } if($didfind==True) { return true; } else { return false; } } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Apr 2002
Location: Houston
Posts: 5,651
|
yea you can you in_array() in place of some of my code above
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
|
This should have you on your way
![]() Code:
$array = array(array(100,200,400), array(100), array(200)); foreach ($array as $array2) { if ($array2[0]==100 && count($array2)==1) { $arrMatches[] = $array2; } } print_r($arrMatches);
__________________
Skype variuscr - Email varius AT gmail |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
Nope, i have that
if (in_array(200,$p2osArr)){print "okay ja -> ";} But this does not ISOLATE 100, it just looks if it there.
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
@Varius: I'll check that. At first glance, what if the array has 2x100. Like this:
$a = array(100,200,100,400);
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Apr 2002
Location: Houston
Posts: 5,651
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
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);
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Confirmed User
Join Date: Apr 2002
Location: Houston
Posts: 5,651
|
Quote:
so the array only has 200 in it. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
That was an example of how the arrays would like when being checked. I thought that was obvious, sorry.
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
i'm a genius, i'm on to something ...
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Chafed.
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
THIS does exactly what i want:
Code:
$a = array(100,100,100); //$a = array(200,100,100); if (in_array(100,$a)){ $tTnt_cnt = array_sum($a); $tItems_cnt = count($a); print (($tTnt_cnt/$tItems_cnt) > 100)?"parcel":"envelope"; }
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Confirmed User
Industry Role:
Join Date: Jul 2001
Location: Utopia
Posts: 6,482
|
Even better, now when they have 4+ items, they have to get parcelpackaging anyhow;-)
*pads self on the back PHP Code:
__________________
seks.ai for sale - ping me |
![]() |
![]() ![]() ![]() ![]() ![]() |