Removing elements from associate array.

This is a discussion on Removing elements from associate array. within the PHP General forums, part of the PHP Programming Forums category; Elo! I've got a problem with removing elements from associate array (php). Above you'll find a schematic structure ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-25-2003
MaciejK
 
Posts: n/a
Default Removing elements from associate array.

Elo!

I've got a problem with removing elements from associate array (php). Above
you'll find a schematic structure of my array:

ARRAY
------
-> ELEMENT1
--> KEY1 => VALUE
--> KEY2 => VALUE
-> ELEMENT2
--> KEY1 => VALUE
--> KEY2 => VALUE
-> ELEMENT3
--> KEY1 => VALUE
--> KEY2 => VALUE
-> ELEMENT4
--> KEY1 => VALUE
--> KEY2 => VALUE

A script I try to prepare is going to remove a single element from this
array leaving others "unharmed" :). If an array consists of only one
element - that's ok, it is removed. If there are two records in an array, a
try to delete second element throws off first one. The more elements in an
array, the more mistakes occurs. I think that the problem is to find an id
of an element (ex. ELEMENT2) (this is the element, that was identified in an
foreach{} loop as an element to remove). I'm sure the solution is very
simple, but i can't get it on (i'm not sure if this word construction is
correct - i am not a native english speaking person). I was looking for the
solution in some sources, but the only thing i have learnt is that to remove
an element from an array is used a unset() command. That's correct - but
how to get an id for an element to remove. If I could ask you to give me an
example of deleting, let's say, second element from the structure i wrote
above.

MaciejK


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:04 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0