0

I have modified a dimensions/shipping calculator and almost got it working as i require except i have hit a hurdle that i can not find a solution too.

what I need is to pass

 $b->add_inner_box($inner_L,$inner_W,$inner_D);

x number of times (set buy a cycle value and $count loop)

this is passed to

public function add_inner_box($l,$w,$h) {
    if ($l > 0 && $w > 0 && $h > 0) {
        $this -> inner_boxes[] = array(
            "dimensions" => $this -> sort_dimensions($l,$w,$h),
            "packed" => false
        );
    }
    return true;
}

I have looked at arr.push and other options but don`t think these will work in my situation, as you can probably tell i am a novice and could do with some guidance as to add the $b->add_inner_box to the array x times

if I use

$b->add_inner_box($inner_L,$inner_W,$inner_D);
$b->add_inner_box($inner_L,$inner_W,$inner_D);
$b->add_inner_box($inner_L,$inner_W,$inner_D);

within the script it works but this will not work in my aplication.

  • 2
    Welcome to the world of programming. What you want is called looping and you have some choices: for, while, foreach. Start using http://php.net/manual/en/ as your reference point. – Siim Kallari Jun 29 '15 at 16:38
  • `while($count--) {$b->add_inner_box(...);}` – vp_arth Jun 29 '15 at 16:54
  • Can you be specific as to why "_will not work in my aplication_"? – AbraCadaver Jun 29 '15 at 16:54
  • @ vp_arth while($count--) {$b->add_inner_box(...);} appears to work but only for the value of $count it does not cycle... not sure if a need a for each loop adding ... is it okay to post the main part of my script on here? – Thehill ShaGGy Jun 30 '15 at 10:19

0 Answers0