Re: Re: resetting arrays

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

 



Agggh, I feel stupid now. I keep on forgetting to use the double equal sign...

Thanks everyone, it is all working now!

Shaw, Chris - Accenture wrote:
Use !==

if (array_search($basket, $baskitems) !== FALSE) {
$pos = array_search($basket, $baskitems);
unset($ses_basket_items[$pos]); $ses_basket_items  =

array_values($ses_basket_items) ;

-----Original Message-----
From: I. Gray [mailto:phpsupport@xxxxxxxxxxxxxxxxxxxx]
Sent: 21 June 2005 14:21
To: php-general@xxxxxxxxxxxxx
Subject:  Re: resetting arrays


*************************************

This e-mail has been received by the Revenue Internet e-mail service.

*************************************

Thanks Al,

That's done it!

unset($ses_basket_items[$pos]); $ses_basket_items  =

array_values($ses_basket_items) ;

They aren't big arrays so I suppose I shouldn't worry about exceeding

memory limits -

http://uk2.php.net/manual/en/function.array-values.php#36837  ?

My only problem now is that I can't seem to delete the first value of

the array.

$basket is the item I want to delete from the array $baskitems....

if (array_search($basket, $baskitems) != FALSE) {
$pos = array_search($basket, $baskitems);
unset($ses_basket_items[$pos]); $ses_basket_items  =

array_values($ses_basket_items) ;
}





Al wrote:

I. Gray wrote:



Hi.

I am sure this is easy, but I can't get this work.  Is there not a php


function that can do this?

I have an array- for example...
[1] => Yellow
[2] => Green
[3] => Purple
[4] => Blue
[5] => Red
[6] => Orange
[7] => Cyan

What happens, say if I delete [3] => Purple?  I get...

[1] => Yellow
[2] => Green
[4] => Blue
[5] => Red
[6] => Orange
[7] => Cyan

But what if I want to reset the numbers? Like...

[1] => Yellow
[2] => Green
[3] => Blue
[4] => Red
[5] => Orange
[6] => Cyan

I've tried this...

unset($ses_basket_items[$pos]); for ($ii=0;


$ii<count($ses_basket_items); $ii++) {if


(isset($ses_basket_items[$ii])) {$cc++; $arry_a[$cc] =


$ses_basket_items[$ii]; }} $ses_basket_items = $arry_a;

where $pos is the position of the array I want to get rid of.


$ses_basket_items is session variable, does that matter?

Please help.



array_values()


--

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





************************

This message has been delivered to the Internet by the Revenue Internet e-mail service

*************************

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux