Questions tagged [unset]

Removing the value associated with a variable or property from the current environment.

Common usages:

  • Destroying a variable or member of an array in PHP.
  • Removing the value bound to a property in Apache Ant.
  • Removing a variable from the environment of a shell script.
595 questions
0
votes
2 answers

Create one instance of an array whilst in a foreach loop

I have myself in a unique situation here and I am not sure if this is the correct way to go about it; I am open to suggestions. I have a function in which it grabs all of the table names in a database and stores them into an array. Next newly parsed…
Hemesh
  • 329
  • 2
  • 3
  • 13
0
votes
6 answers

Unsetting elements from array within foreach

I'm currently working on a generic form creation class and had an issue yesterday. I made a snippet to reproduce the problem. Essentially I want to delete elements that are grouped from the original elements array after the whole group has been…
Chris
  • 1,226
  • 1
  • 12
  • 26
0
votes
2 answers

How to set unset session variable back?

I'm trying to test my php script, so I need to (at least temporarily) get back some of the unset variables. I mean:…
void
  • 1,876
  • 8
  • 24
  • 30
0
votes
1 answer

Unset referenced variable

I created a class to store config values. The code of my Config class: class Config { protected static $params = array(); protected static $instance; private function __construct(array $params=NULL){ if(!empty($params)){ self::$params =…
Stefan Luv
  • 1,179
  • 3
  • 12
  • 28
0
votes
3 answers

Removing an element from an array not working

I have the following code to remove an element from an array: for ($i = 0; $i < count($contracte); $i++) { if ($contracte[$i]['total_luni_contract'] == $contracte[$i]['luni_contract_cu_cheltuieli']) { unset($contracte[$i]); …
Psyche
  • 8,513
  • 20
  • 70
  • 85
0
votes
3 answers

header('location:index.php') redirects me to index.php after refreshing the page for 2 times

I have a php page (index.php) in which after verifying the username and password a session will be set($_SESSION['expire']) that will be expired and unset after 30 mins (30 mins after pressing the login button) and will redirect us to index.php…
Az Dr
  • 90
  • 2
  • 9
0
votes
1 answer

PHP ignoring if statement, unsetting session vars

I have a PHP script that stores a url from which a form was submitted in a session variable and then compares it to the current page url. If it's not the same as the one stored in the session it gets unset, at least that's how it should work. The…
0
votes
1 answer

Unset parent on empty

Please, someone ca help me with that? I want to unset the parent array key if any value inside of that array is null; e.g. array ( 0 => array ( 'type' => 'Main' 'phone' => '11 555-1423' 'foo' => array( 0…
0
votes
2 answers

UNSET doesnt remove/unset array values permanently

I have the following script for a Google maps application. The information about a specific place is sent via ajax to the $array array which is then added to the $SESSION['infomarker']. This part works fine. But the user should also be able to…
user1009453
  • 707
  • 2
  • 11
  • 28
0
votes
2 answers

php unset key in array makes script fail

I am having an issue whan calling unset on an array's key, here is the non-working code $updatedcontact = $_POST; unset($updatedcontact['_id']; I know that the _id key exists (even if it would not my script should still work I guess) because…
Johnride
  • 8,476
  • 5
  • 29
  • 39
0
votes
3 answers

values of sessions vaiables are getting unset i.e. "-blank-" without unsseting it

include('conection.php'); $db=new Database(); session_start(); echo "
".$_SESSION['uid']."
"; if(!(isset(**$_SESSION['uid']**))) { …
surya
  • 109
  • 1
  • 4
  • 13
0
votes
3 answers

PHP - How to find the Auto Increment Array id to unset

I am using a form to create several arrays in a Session. Each time the form is submitted a new $_SESSION['item'][] is made containing each new array. The code for this: $newitem = array ( 'id' => $row_getshoppingcart['id'] , 'icon' =>…
0
votes
1 answer

php 5 variable from javascript not unset

Note: clicking on the left chess piece at http://communitychessclub.com/rabren/index.php?clear=1 is supposed to unset $choice and reload the page. But it just reloads the page. I want to check for a variable state set in javascript. …
verlager
  • 794
  • 5
  • 25
  • 43
0
votes
4 answers

Most Efficient Way to Delete Nested Array Element

Say I have the following: Array( [0] => Array ( [id] => 1 [item] => first item ) [1] => Array ( [id] => 3 [item] => second item ) [2] => Array ( [id] => 5 [item] => third item …
Fluidbyte
  • 5,162
  • 9
  • 47
  • 76
0
votes
1 answer

PHP page is storing form input variables after user submits

I wasn't sure what else to call the title...I have a PHP page that accesses a certain MySQL database, pulls the values from the table, and places them in an HTML form (POST method - PHP_SELF). The user can then view the values, alter them as they…
user1562781
  • 379
  • 1
  • 9
  • 20