PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
arbocenc
Forum Newbie
Posts: 2 Joined: Mon Dec 08, 2003 11:06 pm
Post
by arbocenc » Mon Dec 08, 2003 11:06 pm
Hi,
I'm stuck in a php problem:
Code: Select all
function filtre_editors($var) {
return ($varї"manufacturer_id"] == $listado_editores_dosї$ii]); //funciona si li poso 29..
}
for ($ii=0; $ii<sizeof($listado_editores_dos); $ii++) {
$order_filtrada = array_filter($order->products, "filtre_editors");
sort ($order_filtrada);
}
This code doesn't run because $listado_editores_dos[$ii] has a value after the function definition... And I can not add a $ii like:
Code: Select all
$order_filtrada = array_filter($order->products, "filtre_editors(,Sii)"); because it's wrong...
My PHP skills are no good and I can't look after the solution... Any ideas?
Regards,
Joan
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Tue Dec 09, 2003 1:03 am
You can take advantage of the internal array pointers:
Code: Select all
function filtre_editors($var) {
global $listado_editores_dos;
return ($var["manufacturer_id"] == current($listado_editores_dos)); //funciona si li poso 29..
}
reset($listado_editores_dos);
do{
$order_filtrada = array_filter($order->products, "filtre_editors");
sort ($order_filtrada);
}while (false!==next($listado_editores_dos));
arbocenc
Forum Newbie
Posts: 2 Joined: Mon Dec 08, 2003 11:06 pm
Post
by arbocenc » Tue Dec 09, 2003 7:53 am
Gorgeous!
I think it will run...
Thanks a lot!
Joan