473,770 Members | 4,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unset array

Hi all,

I've created the following code:

<?php

session_start() ;
?>
<FORM METHOD="POST" ACTION="prova.p hp">
Add <b>Combinatio n</b><br><br>
Element 1: <INPUT NAME="el1add" TYPE="TEXT">
<BR>
Element 2: <INPUT NAME="el2add" TYPE="TEXT">
<br>
<INPUT TYPE="SUBMIT" VALUE"Submit">
</FORM>
<br>
<FORM METHOD="POST" ACTION="prova.p hp">

Del <b>Combinatio n</b><br><br>
Element 1: <INPUT NAME="el1del" TYPE="TEXT">
<BR>
Element 2: <INPUT NAME="el2del" TYPE="TEXT">
<br>
<INPUT TYPE="SUBMIT" VALUE"Submit">
</FORM>
<br><br>
Combination<br> <br>
<?php
$_SESSION["combinatio ns"][] =
($_REQUEST["el1add"].$_REQUEST["el2add"]);
unset($_SESSION["combinatio ns"][$_REQUEST["$el1del"]]);
unset($_SESSION["combinatio ns"][$_REQUEST["$el2del"]]);
print_r($_SESSI ON["combinatio ns"]);
?>

I'd like to create an array combinations which includes all the
combinations that I insert through the first form (add combinations).

ref:
$_SESSION["combinatio ns"][] = ($_REQUEST["el1add"].$_REQUEST["el2add"]);

This works fine and is OK.
Then, I'd like to delete from the array combinations all the
combinations that I insert through the second form (del combinations).

ref:
unset($_SESSION["combinatio ns"][$_REQUEST["$el1del"]]);
unset($_SESSION["combinatio ns"][$_REQUEST["$el2del"]]);

This second part doesn't work.
In particular, I want to delete all the elements of the array
$_SESSION["combinatio ns"] that include $_REQUEST["$el1del"] or
$_REQUEST["$el2del"] as text (not as key). I've some problem in doing it.
Can you help me please?
Many thanks.

Cheers,
Nico
Dec 15 '06 #1
1 4507
Nico wrote:
unset($_SESSION["combinatio ns"][$_REQUEST["$el1del"]]);
unset($_SESSION["combinatio ns"][$_REQUEST["$el2del"]]);
^^^
Some extra $-signs in there.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Dec 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2044
by: Xerxes | last post by:
Hi, I have a cart, setup as an associative array (itemid=>qty). When the cart is displayed, the quantity field is an input box and the value can be changed to add/remove an item: echo '<input type = "text" name = "'.$itemid.'" value = "'.$qty.'" size = "3">'; when the "Save changes" button on the page that displays thecart is pressed, a hidden field called "save" is set and the form is submitted.
3
14906
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even after unset() is called. Is there some special setting in PHP that can allow a session to
2
3137
by: Steve | last post by:
I'm working on an e-commerce site, and one of the things I need to do is split an existing order into two orders. The problem I'm having is not creating the new order, but getting the remaining items from the original order cleaned up in the array. What I've tried to do so far is: 1) The data is stored in a serialized array in the order_data field in the orders table. When the order is selected, it is unserialized and called $order_data....
7
1861
by: fasanay | last post by:
Hi everybody I have got the following PHP code which I am trying to convert to ASP any help will be appreciated...I have done most of it but I cant find a replace function for Unset in asp which will discard the variable alltogether... if ($categoryid == "all") { $sql = "SELECT * FROM products where shopinspection=$shopinspection"; unset($HTTP_POST_VARS); unset($HTTP_POST_VARS);
2
8965
by: Georg Weiler | last post by:
Hi, I'm biting my nails on this for several days now, hope that someone of you can help me...: On my page, the user can display tables, created out of a database. So I have several <a href> links to display the various tables. They all look something like: <a href=this_page.php?table=mytable1>the first table</a>
2
1573
by: Iain Adams | last post by:
Hey i have a loop like so, foreach($users as $user) { foreach($syncWebUsers as $sync) { //user already synched if($sync == $user) {
5
2298
by: comp.lang.php | last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA $_POST if ($_POST && (!is_array($leaseObj->errorArray) || @sizeof($leaseObj->errorArray) == 0)) { print_r(array_keys($_POST)); @reset($_POST); $tempPost = $_POST; foreach ($_POST as $key =$val) if (strpos($key, 'new_') === 0) array_remove($tempPost, $tempPost);
2
2033
by: gm04030276 | last post by:
hey, i'm basically trying to use php sessions and a bit of javascript to make tabbed browsing within a web page using sessions to store the data of the different opened pages. Problem: when i unset the first 0 index in the array (ie close the default page) it seems to wipe the other one (can't get it to add more that one anymore) from the array also the information is held in sub array $_SESSION each page has its own array of infomation...
0
1417
Airslash
by: Airslash | last post by:
Hello, I've written a small function to delete a variable from a class' internal array. The variables on their own are custom class objects, and I'm a bit confused about the whole pass by reference thing. First I'll show you the code: # removes a parameter from the array. # variables are passed as reference to prevent overhead.
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.