Square of asterisks
Posted: Fri Oct 11, 2013 8:40 am
now a day I am learning php with loops.
I am solving my assignments how to create square of asterisks.
something is wrong in my code. what is this
I am solving my assignments how to create square of asterisks.
something is wrong in my code. what is this
Code: Select all
<?PHP
$inputs = array();
if (isset($_POST['submit'])) { //to check if the form was submitted
$value = isset($_POST['input0'])? $_POST['input0'] : null;
for($count = 1; $value != null; $count++){
array_push($inputs, $value);
$value = isset($_POST['input'.$count])? $_POST['input'.$count] : null;
}
}
var_dump($inputs);
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<!-- to take multiple inputs copy the below line and change name="input" attribute -->
Enter input 1: <input type="text" name="input0" value="" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php // MY Loop code starts from here
for ($x = 1; $x<=$inputs[0]; $x++)
{
echo "*";
$x = $inputs[0];
if ($x == $inputs[0])
{
echo "<br />";
}
else
{
die();
}
}
?>