Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

remove array element

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

remove array element

Postby mynmonic » Sun Feb 23, 2003 7:01 pm

How can I remove a node from an array ?
Say array[] with size of 10, I want to remove the last 2 elements - array[8] and array[9], and the array size remain 8.
Can I do this with php code?
mynmonic
New php-forum User
New php-forum User
 
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong

Re: remove array element

Postby WiZARD » Mon Feb 24, 2003 1:02 am

You may remove eny element from array like cookies
Code: Select all
array("var01" ->"");

if you try read var01 you have a error :wink:
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

reply

Postby Skeletor » Mon Feb 24, 2003 7:11 am

I believe you can also use the unset function as well:

unset($array[8]);
unset($array[9]);
Skeletor
New php-forum User
New php-forum User
 
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio

Postby mynmonic » Mon Feb 24, 2003 10:25 am

thanks
mynmonic
New php-forum User
New php-forum User
 
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.