Forum Moderators: coopster

Message Too Old, No Replies

Max number in query line.. HELP!

         

Uk_VTI

10:29 am on Jun 3, 2005 (gmt 0)



Hi,

I am trying to find out the max number of one of the values in my querystring.

Eg. www.myhost.com/index.php?var1=text&var2=text&var3=text&var4=&var5=

what i need to do is find out which var* with a value is the biggest... its is really hard to explain but the above example would return 3 because although the var* goes to var5, var5 has no value...

another example:
www.myhost.com/index.php?var1=text&var2=text&var3=text&var4=&var5=othertext&var6=

this would return 5.

Can anyone help? Sorry about the description!

Blackie

11:59 am on Jun 3, 2005 (gmt 0)

10+ Year Member



If you know total amount of variables then simply loop through them remembering the last one with a value.

First fill the array @var with your var* values, then something do like this:

for ($i=1;$i<VarsAmount;$i++) {
if ($var[$i]!='') $last_one_index = $i;
}

When you are out of the script you have your number as a value of $last_one_index.

Hope this helps.

jatar_k

4:38 pm on Jun 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



and Welcome to WebmasterWorld Uk_VTI