note 77849 added to function.array-splice
| From: | saurabhmdh at yahoo dot co dot on | Date: | Sat, 15 Sep 2007 19:29:25 +0000 |
| Subject: | note 77849 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130525@lists.php.net to get a copy of this message | ||
for inserting array in 2-d array, according x position, y position
function add_module_xy($x_loc, $y_loc, $module) {
//identify the column of the modules
switch ($x_loc) {
case 1:
$x = 'left';
break;
case 2:
$x = 'middle';
break;
case 3:
$x = 'right';
break;
default:
throw new Exception("", "Invalid horizontal position $x_loc");
}
$max_y_loc = count($this->module_arrays[$x]) + 1;
if ($y_loc > $max_y_loc) {
//if y location is greater then max array index then add module to last
$y_loc = $max_y_loc;
}
$left = array_slice ($this->module_arrays[$x], 0, $y_loc-1);
$right = array_slice ($this->module_arrays[$x], $y_loc-1);
$insert[0] = $module;
$array = array_merge ($left, $insert, $right);
$this->module_arrays[$x] = $array;
}
----
Server IP: 203.220.0.234
Probable Submitter: 122.162.226.186
----
Manual Page -- http://www.php.net/manual/en/function.array-splice.php
Edit -- https://master.php.net/note/edit/77849
Del: integrated -- https://master.php.net/note/delete/77849/integrated
Del: useless -- https://master.php.net/note/delete/77849/useless
Del: bad code -- https://master.php.net/note/delete/77849/bad+code
Del: spam -- https://master.php.net/note/delete/77849/spam
Del: non-english -- https://master.php.net/note/delete/77849/non-english
Del: in docs -- https://master.php.net/note/delete/77849/in+docs
Del: other reasons-- https://master.php.net/note/delete/77849
Reject -- https://master.php.net/note/reject/77849
Search -- https://master.php.net/manage/user-notes.php