Jump to content

[SOLVED] make my code even shorter please help.


redarrow

Recommended Posts

Advance thank you.

 

I was creating a secret number picker,

 

it all works but i wonder if you can shorten the code for me....

 

i can not think of anything else to shorten the code....

 

can u....

 

cheers

 

i will add md5 and sha1 for security soon.

 

<?php

if(isset($_POST['submit'])){

$secret_number=$_POST['a'].$_POST['b'].$_POST['c'].$_POST['d'];

if($secret_number=='0000'){

	$secret_number=" ";
}

echo $secret_number;
}

echo "<form method='POST'>";

$sname=array("a","b","c","d");

$number=array(0,1,2,3,4,5,6,7,8,9);

foreach($sname as $sname){

echo"<select name='$sname'>";


for($i=0; $i<count($number); $i++){

	echo"<option value='$number[$i]'>$number[$i]</option>";
}


  echo  "</select>";

}

echo "<br /> <br/> <input type='submit' name='submit' value='Send!'>";

echo"</form>";

?>

 

 

if(isset($_POST['submit']))
echo implode($_POST['number']);

echo "<form method='POST'>";
$numbers = range(0, 9);
ob_start();
echo "<select name='number[]'>";
foreach($numbers as $number)
echo "<option value='$number'>$number</option>";
echo "</select>";
$ele = ob_get_contents();
echo $ele, $ele, $ele, "<br /><br /><input type='submit' name='submit' value='Send!'></form>";

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.