[PHP] Multidimensional Array manipluation...

2003-01-02 Thread Dhaval Desai
Hello ppl,

I was trying to do something with an array...I guess you could see what I 
mean from the code below:


$test[0] = hey;
$test[1] = hi;
$test[2] = hello;

Now I want to hold various values in $test[0][hey] = 1 and 
$test[1][hi] = 2 and $test[2][hello] = 3
and then I want to use the function let's say in_array(hey, $test) and if 
it's found in the array I want to update the value in that array from 1 to 
1+1 or anything...

All of the above would be done dynamically from database, the above is just 
to get the Logic..I hope it's possible...I am keeping my fingers crossed...

Thank You
Best Regards,
Dhaval


_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Chris Shiflett
--- Dhaval Desai [EMAIL PROTECTED] wrote:
 $test[0] = hey;
 $test[1] = hi;
 $test[2] = hello;
 
 Now I want to hold various values in $test[0][hey] =
 1 and $test[1][hi] = 2 and $test[2][hello] = 3

Try this instead:

$test[0][hey] = 1;
$test[1][hi] = 2;
$test[2][hello] = 3;

Also, remember that you can often learn these types of
things with trial and error by using the print_r()
function:

print_r($test);

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Dhaval Desai
Hi,

Thanx for the reply, well but what about the second part or my mail..

I want to use in_array(value, $array);
and if found, I want to update the value of that variable...


$test[0][hey] = 1;
$test[1][hi] = 2;
$test[2][hello] = 3;


I want to update $test[0][hey] and set it as 1+1;
I think it's possible using splice()m I don't know exactly how to use it 
with Multi Dimensional arrays

Also is there any idea on how can we count() the values in a multi 
dimensional arrays...


Thanx




From: Chris Shiflett [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Dhaval Desai [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [PHP] Multidimensional Array manipluation...
Date: Thu, 2 Jan 2003 09:04:27 -0800 (PST)

--- Dhaval Desai [EMAIL PROTECTED] wrote:
 $test[0] = hey;
 $test[1] = hi;
 $test[2] = hello;

 Now I want to hold various values in $test[0][hey] =
 1 and $test[1][hi] = 2 and $test[2][hello] = 3

Try this instead:

$test[0][hey] = 1;
$test[1][hi] = 2;
$test[2][hello] = 3;

Also, remember that you can often learn these types of
things with trial and error by using the print_r()
function:

print_r($test);

Chris



_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Chris Shiflett
 $test[0][hey] = 1;
 $test[1][hi] = 2;
 $test[2][hello] = 3;
 
 I want to update $test[0][hey] and set it as 1+1;

If you just want to increment the value:

$test[0][hey]++;

 Also is there any idea on how can we count() the values
 in a multi dimensional arrays...

The function array_count_values() might give you what you
want. What are you wanting to count exactly?

A good reference for you online is:

http://www.php.net/manual/en/ref.array.php

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Multidimensional Array manipluation...

2003-01-02 Thread Dhaval Desai
Hi,

Well, I will be having something like this:

$se5f2254321s65s32s65[] will hold various valus like jan_1,jan-2,jan_3,jan_4 
etc and then jan_1 will hold 1, jan_2=2,, jan_3=1 etc etc...

Depending on certain conditions, I want to increment the values of certain 
values in the array...like...
for($i=0; $i=count($se5f2254321s65s32s65); $i++)
  {
  $se5f2254321s65s32s65[$i][jan_1] = 1
  }
I want to increment it with 1 and so on for the various other values


Thanx

Best Regards,
Dhaval





From: Chris Shiflett [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Dhaval Desai [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: [PHP] Multidimensional Array manipluation...
Date: Thu, 2 Jan 2003 09:30:43 -0800 (PST)

 $test[0][hey] = 1;
 $test[1][hi] = 2;
 $test[2][hello] = 3;

 I want to update $test[0][hey] and set it as 1+1;

If you just want to increment the value:

$test[0][hey]++;

 Also is there any idea on how can we count() the values
 in a multi dimensional arrays...

The function array_count_values() might give you what you
want. What are you wanting to count exactly?

A good reference for you online is:

http://www.php.net/manual/en/ref.array.php

Chris



_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php