[PHP] delete an element from an array

2001-03-05 Thread kaab kaoutar

Hi!
how can i decrement the length of an array!
In fact i'm trying to delete an element from an array , i'v put the content 
of i in i-1 (loop) and i tried to decrement the array legnththis way: 
count($x)=count($x)-1;
but it generates an error!

Thanks

_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] delete an element from an array

2001-03-05 Thread kaab kaoutar


Hi!
FIRST OF ALL THANKS !
well do u mean that the only way to remove an elemnt from an array is to
copy it into another array? it does not suit me cause the array is a session 
variable and i need to update it !

Thanks
_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] delete an element from an array

2001-03-05 Thread kaab kaoutar

Thanks! but i know this function!
i can't do that cause my varibale is multidimenssional, and i don't want to 
update all that ! for one element !
we can't decrement the length of the array ?! no way ?



From: Hardy Merrill [EMAIL PROTECTED]
To: kaab kaoutar [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: [PHP] delete an element from an array
Date: Mon, 5 Mar 2001 10:57:49 -0500

Have a look at

 http://www.php.net/manual/en/function.unset.php

"unset" may do what you want.

HTH.

--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

kaab kaoutar [[EMAIL PROTECTED]] wrote:
 
  Hi!
  FIRST OF ALL THANKS !
  well do u mean that the only way to remove an elemnt from an array is to
  copy it into another array? it does not suit me cause the array is a 
session
  variable and i need to update it !
 
  Thanks
  
_
  Get Your Private, Free E-mail from MSN Hotmail at 
http://www.hotmail.com.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] delete an element from an array

2001-03-05 Thread Hardy Merrill

kaab kaoutar [[EMAIL PROTECTED]] wrote:
 Thanks! but i know this function!
 i can't do that cause my varibale is multidimenssional, and i don't want to 
 update all that ! for one element !
 we can't decrement the length of the array ?! no way ?

Here's an example of a multidimensional array - I "unset" one
of the values in the middle - I don't know why this won't work
for you:

?
   $arr1 = array("a" = array('1' = "a111",
  '2' = "a222",
  '3' = "a333"),
 "b" = array('1' = "b111",
  '2' = "b222",
  '3' = "b333"),
 "c" = array('1' = "c111",
  '2' = "c222",
  '3' = "c333"));
   foreach ($arr1 as $key1 = $value1) {
  echo "br";
  echo "key=[$key1], value=[$value1]br";
  foreach ($value1 as $key2 = $value2) {
 echo "  key2=[$key2], value2=[$value2]br";
  }
   }
 
   unset($arr1["b"]["2"]);
   echo "brbrUnset b2 nowbrbr";
 
   foreach ($arr1 as $key1 = $value1) {
  echo "br";
  echo "key=[$key1], value=[$value1]br";
  foreach ($value1 as $key2 = $value2) {
 echo "  key2=[$key2], value2=[$value2]br";
  }
   }
 
?  

Here's the output displayed on the browser:
---

key=[a], value=[Array]
key2=[1], value2=[a111]
key2=[2], value2=[a222]
key2=[3], value2=[a333]

key=[b], value=[Array]
key2=[1], value2=[b111]
key2=[2], value2=[b222]
key2=[3], value2=[b333]

key=[c], value=[Array]
key2=[1], value2=[c111]
key2=[2], value2=[c222]
key2=[3], value2=[c333]


Unset b2 now


key=[a], value=[Array]
key2=[1], value2=[a111]
key2=[2], value2=[a222]
key2=[3], value2=[a333]

key=[b], value=[Array]
key2=[1], value2=[b111]
key2=[3], value2=[b333]

key=[c], value=[Array]
key2=[1], value2=[c111]
key2=[2], value2=[c222]
key2=[3], value2=[c333]


 
 
 
 From: Hardy Merrill [EMAIL PROTECTED]
 To: kaab kaoutar [EMAIL PROTECTED]
 CC: [EMAIL PROTECTED]
 Subject: Re: [PHP] delete an element from an array
 Date: Mon, 5 Mar 2001 10:57:49 -0500
 
 Have a look at
 
  http://www.php.net/manual/en/function.unset.php
 
 "unset" may do what you want.
 
 HTH.
 
 --
 Hardy Merrill
 Mission Critical Linux, Inc.
 http://www.missioncriticallinux.com
 
 kaab kaoutar [[EMAIL PROTECTED]] wrote:
  
   Hi!
   FIRST OF ALL THANKS !
   well do u mean that the only way to remove an elemnt from an array is to
   copy it into another array? it does not suit me cause the array is a 
 session
   variable and i need to update it !
  
   Thanks
   
 _
   Get Your Private, Free E-mail from MSN Hotmail at 
 http://www.hotmail.com.
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] delete an element from an array

2001-03-05 Thread Christian Cresante

Since its the last element, just pop it out:
array_pop()

--- kaab kaoutar [EMAIL PROTECTED] wrote:
 Hi!
 how can i decrement the length of an array!
 In fact i'm trying to delete an element from an
 array , i'v put the content 
 of i in i-1 (loop) and i tried to decrement the
 array legnththis way: 
 count($x)=count($x)-1;
 but it generates an error!
 
 Thanks
 

_
 Get Your Private, Free E-mail from MSN Hotmail at
 http://www.hotmail.com.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 To contact the list administrators, e-mail:
 [EMAIL PROTECTED]
 


__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]