note 76077 added to ref.array

From: Date: Thu, 28 Jun 2007 23:34:07 +0000
Subject: note 76077 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-128068@lists.php.net to get a copy of this message
This is a code remove an other row of array <?php //$mang is an array, $id is index of row in array function remove($mang,$id) { $flag = false; $count = count($mang); $i = 0; while ($flag!=true && $i<$count) { if ($i==$id) { unset($mang[$i]); $flag = true; $index = $i; } else { if ($temp) { array_push($temp,$mang[$i]); } else { $temp = array($mang[$i]); } } $i++; } if ($flag) { while ($index<$count) { if ($temp) { array_push($temp,$mang[$index+1]); } else { $temp = array($mang[$index+1]); } $index++; } } array_pop($temp); return $temp; } $arr = array(array("id"=>"1","name"=>"b"),array("id"=>"2","name"=>"d")); array_push($arr,array("id"=>"3","name"=>"f")); array_push($arr,array("id"=>4,"name"=>"g")); $arr = remove($arr,2); echo "<pre>"; print_r($arr); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 58.187.77.63 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/76077 Del: integrated -- https://master.php.net/note/delete/76077/integrated Del: useless -- https://master.php.net/note/delete/76077/useless Del: bad code -- https://master.php.net/note/delete/76077/bad+code Del: spam -- https://master.php.net/note/delete/76077/spam Del: non-english -- https://master.php.net/note/delete/76077/non-english Del: in docs -- https://master.php.net/note/delete/76077/in+docs Del: other reasons-- https://master.php.net/note/delete/76077 Reject -- https://master.php.net/note/reject/76077 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128068) next »