RE: [PHP-WIN] Array question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well its not exactly what I was looking for but you gave me some ideas,
but still got this small problem:

If I know the value in the array, say for example 49. Then I want to
store the previous and next value in the array? I know the other way
when I have the position, just use pos($dataarray) then like you sad
$dataarray($key+1), that's easy. But the other way????


-----Original Message-----
From: Warren Vail [mailto:warren@vailtech.net] 
Sent: den 25 augusti 2003 09:33
To: Disko_kex; php-windows@lists.php.net
Subject: RE: [PHP-WIN] Array question

in my experience, using numeric indices to your array, you can deposit
and
reference occurances as follows;  however your reference is not a valid
array definition;

[0] => 1 [1] => 2 [2] => 3 ... [99] => 100  (I don't believe these are
valid
as a definition)

numeric indices would be defined as follows;

array(0 => 1, 1 => 2, 2 => 3  ....  99 => 100);

$x = $dataarray[50];

$dataarray[50 - 2] = $x;
$dataarray[50 + 1] = $x;

if($dataarray[71] == 74) do this....

On the other hand, if the indices is alpha-numeric string
representations of
numbers,

array("0" => 1, "1" => 2, "2" => 3 ... "99" => 100)

you will need to use some other tricks to access them.

hope this is what you are looking for, you used several terms like
"select"
and "know the value" of that are somewhat ambiguous ;-)

Warren Vail
warren@vailtech.net


-----Original Message-----
From: Disko_kex [mailto:disko_kex@swedish-mushroom.com]
Sent: Sunday, August 24, 2003 11:59 PM
To: php-windows@lists.php.net
Subject: [PHP-WIN] Array question


If I have an array like this > [0] => 1 [1] => 2 [2] => 3 ... [99] =>
100

If I want to select [50] => 51 and store the value that's 2 positions
before and 1 position after, how can I do?

If I want to know what position value 71 have?


I have search the PHP-manual and found some functions as prev, next, pos
etc. But with these commands I have to loop thru the array every time to
reach the the values and positions. It has to be an easier way to do it.

// jocke

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux