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

PHP unset Not Working as expected

I am simply trying to remove all of the Array objects that have 'visible' set to…
ChristopherStrydom
  • 7,338
  • 5
  • 21
  • 34
0
votes
1 answer

Joomla - framework.php unset my vars

I use the Joomla (1.5.26) authentification in an external PHP web application. My problem is that the included joomla file "framework.php" unsets any variable previously defined. // some code $varfoo = 'toto'; define( '_JEXEC', 1…
user1985014
  • 91
  • 1
  • 1
  • 3
0
votes
3 answers

How do I delete array elements one by one every time I reload the page?

How do I remove each array element one by one every time I refresh the page?
0
votes
1 answer

Using isset() to validate whether a user is logged in on a website

Is using isset() a good way to validate whether a user has logged in, and then using unset() when the user logs back out to destroy the variable.
Fluffeh
  • 33,228
  • 16
  • 67
  • 80
0
votes
0 answers

PHP Object new method for Class, Memory Leak and Unset Method

I have Created following class in flie index.class.php :- and now, I am using it like below in my…
john smith
  • 93
  • 3
  • 12
0
votes
1 answer

Yii - Manipulating a sesssion variable

I am a still a newbie when it comes to using YII, but I been working with session variables for the past few days, and I can't seem to grasp to the concept behind my error. Any advice will be appreciated. My add function works perfectly so far, for…
user2205196
  • 113
  • 1
  • 2
  • 10
0
votes
3 answers

Confusion between false and 0 arrays

Basically I have the following code : unset($items[array_search($i,$items)]); When the key is not found the array_search returns false which is equivalent to returning 0, which results in deleting the element 0 of the array if an item value is not…
Faouzi FJTech
  • 981
  • 3
  • 13
  • 27
0
votes
1 answer

unset variable in foreach recursively

I need build tree hierarchy through recursion. All working fine without php unset, but I want unset elements which already been built. Problem: In code below unset working, but break the first recursion call, so from the example data category…
user1156168
  • 936
  • 13
  • 32
0
votes
2 answers

Undefined index in deleting $_SESSION

I have this code to delete any idea from a cart... I need to delete two$_SESSION. 1) $_SESSION["cart_array"] 2 $_SESSION["minicart"] Without me adding $_SESSION["minicart"] it does delete the $_SESSION["cart_array"] but when i added it i got the…
Amy
  • 55
  • 10
0
votes
1 answer

Replace single value in multidimensional array

I am trying to unset/remove then replace/update a single value from a post meta field, but my code for array_push() and unset() are removing all of the values from each array. Here are the two halves of the code I am currently using. First, to find…
Kyle
  • 422
  • 1
  • 6
  • 10
0
votes
1 answer

PHP unset array in multiple foreach

I have an array that contains ip addresses and their respective subnet information. In a first time, I have to add the subnets informations into my database but I'm trying to do so without any duplicate, with this code #Note that this is…
Cocotton
  • 910
  • 2
  • 7
  • 22
0
votes
2 answers

PHP Session and it's variables

When user come to site by link with activation code, his account activated (changed value in DB) and I want show some info message. For this I reload page with $_SESSION['message'] = "activated" (same time removing activation code from URL). Info…
user2443795
  • 144
  • 7
0
votes
2 answers

What is the benefit in using 'unset'?

The PHP manual says 'unset() destroys the specified variables.' It has the following example: The above code will output: bar So what…
user2312612
0
votes
2 answers

Foreach and unset()

Ran into a little snag and wondering if there is a "best practices" way around it. So I just learned that "A php foreach will execute on the entire array regardless. Test unsetting a value that is next in iteration. It will iterate on the offset,…
TheEditor
  • 486
  • 1
  • 4
  • 18
0
votes
1 answer

How does one unset an array element in ASP classic?

Is there an ASP Classic equivalent to PHP unset(array1[3]) function?
reformed
  • 4,505
  • 11
  • 62
  • 88