unset

PHP Unset + Undefined Offset

I'm having a little trouble with losing my array order after using unset(). Here's the code first: $id = $_GET['id']; for($i = 0; $i < count($my_array); $i++) { if($my_array[$i] == $id) { unset($my_array[$i]); } } Assume that $my_array has 4 items and $my_array[1] is equal to $id. After I unset that I try to run a ...

What is the best method for memory cleanup in PHP? (5.2)

Hi, I have two simple questions. What is better/useful for memory cleanup. $var = null; or unset($var); I have one function with one cycle. I am getting (after few minutes) Fatal error: Allowed memory size of 419430400 bytes exhausted I am setting null and unset()-ing every object (at the end of the cycle) but still without any...

How to remove a node if it exists with simpleXML

So I know the exact path the node I would be attempting to remove. I am iterating through several xml files to update some of the content. In order to add some of the new content in, I must first delete the content that already exists. Here is the code I attempted to use, but I'm receiving a Parse error: syntax error, unexpected T_UNS...

PHP: Removing items from a session

I'm having trouble removing items in a session array in a shopping cart project. The following code should take the selected item and remove it from the session. However the end result is just the same session as before with nothing removed. I've seen similar problems by googling, but haven't found a working solution yet. Here is the str...

unset a element of an array via reference

I can access anywhere inside the multi-dimensional an array via reference method. And I can change the its value. For example: $conf = array( 'type' => 'mysql', 'conf' => array( 'name' => 'mydatabase', 'user' => 'root', 'pass' => '12345', 'host' => array( '127.0...

Does extra space slow down the processor?

After learning how to "correctly" unset a node, I noticed that using PHP's unset() function leaves the tabs and spaces behind. So now I have this big chunk of white space in between nodes at times. I'm wondering if PHP iterates through blank spaces/returns/tabs and whether it would eventually slow down the system. I'm also asking whethe...

php - unset $this

I've made a class that acts like an file wrapper. When user call delete method, i want to unset the object (actually $this). Is there a way (workaround) to do that? The manual said no, there is no way... ...

Sessions get messed up on external host.

The problem sounds like this: The log-in using sessions works perfect on my localhost, but when the EXACTLY same files are uploaded to my host (hostgator), the sessions don't or, or they get messed up. Also the log-out feature doesn't work on the host. I've checked and every page has the session_start(); inside it. The session is not d...

Get $_SESSION position with &

Why this code doesn't work? public function get($key) { return isset($_SESSION[$key]) ? &$_SESSION[$key] : false; } Error Parse error: syntax error, unexpected '&' in C:\Arquivos de programas\EasyPHP-5.3.3\www\myphpblog\code\sessionstorage.class.php on line 12 Thank you. ...