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
4 answers

PHP Unset via References

I have been reading the PHP manual about references and something is confusing me. It says that references are not pointers to memory addresses but rather... Instead, they are symbol table aliases. Isn't this essentially a pointer if the…
Louis
  • 4,172
  • 4
  • 45
  • 62
0
votes
5 answers

Conceptually what happens to a php array if all its elements are unset?

Conceptually what happens to an array that has all of its elements unset? Please see the below code for and example: $ourArray = array( "1", "2", "3", "4" ); foreach($ourArray as $key => $value){ unset($ourArray[$key]) } In…
Samuel Hawksby-Robinson
  • 2,652
  • 4
  • 24
  • 25
0
votes
2 answers

Speeding up PHP foreach loop with unset()?

Based on what I have read about the internals of php arrays this may not be possible, but I wanted to run this past you and see if there's a chance... I am pulling two results sets from a SQL query. One is an array of customers (an array of arrays,…
Joel Joel Binks
  • 1,628
  • 5
  • 27
  • 47
0
votes
1 answer

Trying to delete value in array, using unset. PHP

Reading elements from $file to array, return value of array[0] then delete element and save array to file unset is not working, why ? here is code: list.txt - file(1kb) 10 lines. function files($files) { $list = array(); …
0
votes
1 answer

i am try many things but my site cookie as not unset

my site under domain like this: www.123.com/new full site code under the new folder include index page. i am set the cookie in in remember me click cookie is create cookie code like…
0
votes
1 answer

Array if contains value, unset

I got follow array ($json_output): array(3) { ["ProductsSummary"]=> array(4) { ["Records"]=> int(500) ["TotalRecords"]=> int(5720) ["TotalPages"]=> int(12) ["CurrentPage"]=> int(2) } ["Products"]=> …
user3047382
  • 29
  • 1
  • 2
  • 6
0
votes
1 answer

Remove "unset" from terminal prompt

I was editing my .bashrc in my raspberry pi home directory, and now terminal prompt is stuck as follows: [pi@hostname ~]$ unset I can't delete unset from the prompt. What did I do, and how do I fix this?
corneria
  • 608
  • 3
  • 11
  • 24
0
votes
1 answer

Adding PHP.ini file to directory, then calling PHP file by AJAX causes $_SESSION values to unset, but the session ID to remain the same

I am having problems with my $_SESSION values becoming unset. It all started when my host said that I had to put a PHP.INI file in the root directory of my application. I created the following PHP.ini file and put it in the root directory…
Luke
  • 22,826
  • 31
  • 110
  • 193
0
votes
1 answer

PHP class unset/purge private array variable

I'm trying to make an error logging class, I have some functions to set up various output methods like DB, file, return and screen. I want all errors to be stored into an array and when __destruct() is called, I want to stop the client from waiting…
Chris
  • 668
  • 7
  • 18
0
votes
2 answers

Unset one Array on the basis of another array value in php?

How can I remove one array index on the basis of another array value. For example- Array1 ( [0] => @@code [1] => @@label [2] => @@name [3] => @@age ) Array2 ( [0] => 123jj [1] => test [2] => john [3] => 45 ) Array3 ( [0] => 2 #2 is index to be…
unknownbits
  • 2,855
  • 10
  • 41
  • 81
0
votes
1 answer

PHP: can't unset within an if in a foreach

So I have an associative array, $data, pulled from a $_POST. Looping through with a foreach to reorder things as I want them for later in the program, like moving certain key->values into a "privacy" array as below, and I've come across a snag…
Jeff
  • 17
  • 6
0
votes
5 answers

Indirect modification of overloaded element of CHttpSession has no effect

Iam trying to remove an element from session array in Yii using the following code. $session = Yii::app()->session; $arraylen = count($session['the_variable']); for ($i = 0; $i < $arraylen; $i++) { if…
anu
  • 458
  • 2
  • 13
  • 36
0
votes
1 answer

Unset Not Clearing Array Key/Value

I have form submission that redirects based on the results of a survey. On the landing page, I call a function to process query string, query the database and return results as an array for in-page processing. function surveyResults() { …
macgregor
  • 147
  • 8
0
votes
3 answers

Close db connection

i've founded in the web a class that i needed. This class during her lifecycle open a connection with a local MySql db. In my code the scope of this class instance is local, like this example function doSomething(){ $class = new MyClass(); …
user2540463
  • 112
  • 1
  • 3
  • 10
0
votes
1 answer

How to use default value if unset parameter is an object

I need to build a method where an object is passed as parameter. This method is using PHP "instanceof" shortcut. //Class is setting a coordinate. class PointCartesien { //PC props private $x; private $y; //Constructor public…
Pobe
  • 2,693
  • 1
  • 17
  • 24