note 163 added to gtk.gtkclist.method.remove.php
| From: | altherda@php.net | Date: | Fri, 19 Jul 2002 18:19:54 +0000 |
| Subject: | note 163 added to gtk.gtkclist.method.remove.php | ||
| Groups: | php.gtk.webmaster | ||
| Request: | Send a blank email to php-gtk-webmaster+get-517@lists.php.net to get a copy of this message | ||
If you try to remove multiple rows from a CList at one time by iterating on the $clist->selection
array, note that said array will change as rows are removed. Thus, the following code does not work
as intended:
/* invalid example 1 */
for($i=0;$i<count($clist->selection);$i++){
$clist->remove($clist->selection[$i]);
}
Nor will the following in which a static copy of the initial selection array is used:
/* invalid example 2 */
$cur_sel = $clist->selection;
for($i=0;$i<count($cur_sel);$i++){
$clist->remove($cur_sel[$i]);
}
However, both of the examples below have the same functionality and work as intended:
/* valid example 1 */
while(count($clist->selection)>0){
$clist->remove($clist->selection[0]);
}
/* valid example 2 */
$cur_sel = $clist->selection;
for($i=0;$i<count($cur_sel);$i++){
$clist->remove($cur_sel[$i]-$i);
}
http://gtk.php.net/manual/en/gtk.gtkclist.method.remove.php