array_fill help
Posted: Mon Aug 25, 2008 1:49 am
Hi
I'm using this code:
The array it generates is:
[1] => serial2
[2] => serial2
This is wrong. I want it to generate:
[1] => serial1
[2] => serial2
[3] => serial3
.......
Why doesn't it work??
Help...
Thanks
I'm using this code:
Code: Select all
<?php
$row = 1;
$no_purchased = $_POST['no_purchased'];
while($row <= $no_purchased)
{
$serial = "serial".$row;
$strings = array_fill(1, $no_purchased, $serial);
$row++;
}
foreach ($strings as $testcase)
{
if (ctype_digit($testcase))
{
$valid = "Yes";
}
else
{
$valid = "No";
}
}
if ($valid == "No")
{
print_r ($strings);
}
else
{
print_r ($strings);
}
?>
[1] => serial2
[2] => serial2
This is wrong. I want it to generate:
[1] => serial1
[2] => serial2
[3] => serial3
.......
Why doesn't it work??
Help...
Thanks