Jump to content

Combining variables to make another....


modcar

Recommended Posts

OK, so I have a php loop with

$num += '1';

at the beginning of the loop

 

What Im wanting to do is have variables names according to the number of loops

 

Code I have:

 

$total_to_pay_unrounded = $row['cust_total'] / $num_weeks;
	$total_to_pay = number_format($total_to_pay_unrounded, 2, '.', '');

 

I wanting to achieve is:

 

$total_to_pay_unrounded_1 = $row['cust_total'] / $num_weeks;
	$total_to_pay_1 = number_format($total_to_pay_unrounded_1, 2, '.', '');

$total_to_pay_unrounded_1 = $row['cust_total'] / $num_weeks;
	$total_to_pay_2 = number_format($total_to_pay_unrounded_2, 2, '.', '');

 

etc etc

 

Any assistance is appreciated

Link to comment
https://forums.phpfreaks.com/topic/208078-combining-variables-to-make-another/
Share on other sites

its def

$num + '1';

 

I have it on a previous page in a form

 

<td><strong>Vehicle <? echo $num; ?></strong></td>
    <td> </td>
  </tr>
  <tr>
    <td>Make<span class="formRedStar">*</span></td>
    <td><input name="car<? echo $num; ?>_make" type="text" id="car<? echo $num; ?>_make" value="<? echo $make; ?>" size="20" />

</td>

 

and the page reads Vehicle 1, Vehicle 2 etc

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.