06-27-2009, 06:56 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jun 2009
Posts: 20
Thanks: 2
|
some problem in array_search and the use of unset
dear friend..
PHP Code:
/*when i try to execute this code its working perfect.You need to notice one point in the output while removing the element-*/
Array
(
[0] => s
[1] => a
[2] => r
[4] => f
)
[0] => s
[1] => a
[2] => r
[3]=> Nothing here
[4] => f
/*You see that there is no index-3 in the array. Not acceptable. You have done great work.so now i wanted to use this function*/
array_remove_value($arr, $value){
return array_diff($arr, array($value));
}
/*but i am unable to use it in my code..please help me how to use it.here is my code*/
php Code:
<?phpfunction extract1 ($this){//if i have a parent if($this-> parent) { try { //if i can be removed from parent's contents array; array_splice($parent-> content, $this); // here is doubt. } catch (Exception $e) { } } $lastChild= $this-> lastRecursiveChild(); $nextElement = $lastChild-> next; if($this-> previous) { $this-> previous-> next= $nextElement; } if($nextElement) { $nextElement-> previous= $this-> previous; } $this-> previous= null; $lastChild-> next = Null; $this-> parent = Null; if ($this-> previousSibling) { $this-> previousSibling-> nextSibling = $this-> nextSibling; } if ($this-> nextSibling) { $this-> nextSibling-> previousSibling = $this-> previousSibling; } $this-> previousSibling = $this-> nextSibling = Null; return $this; }?>
please check try block.
thanks
Note added by: Codefreak, please format your code,
Prettifying Pasted Code on TalkPHP
Last edited by codefreek : 06-28-2009 at 10:48 AM.
Reason: PHP tags added - please read http://www.talkphp.com/lounge/4563-prettifying-pasted-code-talkphp.html
|
|
|
|