I'm working on project where I'm preparing a large array set to create a function that will save the value into the database one by one.
So that I created a loop to generate the array as plain text format that I need
$i = 1;
while( $i <= 65 ) {
$startVal = $this->summe(35501, 500);
$endVal = $this->summe(36000, 500);
$amount = $this->summe(3575, 50);
echo "array(<br>";
echo "'low' => '".$startVal."',<br>";
echo "'high' => '".$endVal."',<br>";
echo "'amount' => '".$amount."',<br>";
echo '\'city\' => $city<br>';
echo "),<br>";
$i++;
}
But there is a small issue that whenever I run the code, every time loop return same value:
array(
'low' => '36001',
'high' => '36500',
'amount' => '3625',
'city' => $city
),
array(
'low' => '36001',
'high' => '36500',
'amount' => '3625',
'city' => $city
),
array(
'low' => '36001',
'high' => '36500',
'amount' => '3625',
'city' => $city
),
array(
'low' => '36001',
'high' => '36500',
'amount' => '3625',
'city' => $city
),
But I need to generate output like following format:
array(
'low' => '36001',
'high' => '36500',
'amount' => '3625',
'city' => $city
),
array(
'low' => '36501', // Adding 500
'high' => '37000', // Adding 500
'amount' => '3675', // Adding 50
'city' => $city
),
array(
'low' => '37001', // Adding 500
'high' => '37500', // Adding 500
'amount' => '3725', // Adding 50
'city' => $city
),
array(
'low' => '37501', // Adding 500
'high' => '38000', // Adding 500
'amount' => '3775', // Adding 50
'city' => $city
),
$this->summe(35501, 500 * $i)