php program help please!!!!?
really need this program but can’t make it no matter how hard i try
if a user types w e r g i in one test field,
the return should be
Total Number of elements: 5
Heighest element: w
Lowest element: e
please help me out here. i m new 2 php and really need it. thank you.
two files:
1) input.html
<HTML>
<BODY>
<center>
<form method=’post’ action=’xhi.php’ >
Please enter the alphabets:
<input type=’textbox’ length=30 name=’alpha’ />
<input type=’submit’ value=’submit’ />
</form>
</center>
</BODY>
</HTML>
2) xhi.php
<?php
$entered_val = explode(" " , $_POST['alpha']);
$total_char = 0;
$high = ‘a’;
$low = ‘z’;
//declaring array $arr
$arr = array(‘a’,'b’,'c’,'d’,'e’,
‘f’,'g’,'h’,'i’,'j’,'k’,'l’,'m’,'n’,'o’
,’p',’q',’r',’s',’t',’u',’v',’w',’x’
,’y',’z');
//associating value with alphabets a=1, b=2, z=26
// in $find
for($i=0;$i<count($arr);$i++){
$find[$arr[$i]]=$i+1;
}
for($i=0;$i<count($entered_val);$i++){
if($find[$entered_val[$i]]<$find[$low]){
$low = $entered_val[$i];
}
if($find[$entered_val[$i]]>$find[$high]){
$high = $entered_val[$i];
}
}
echo "Total number of elements : " . count($entered_val);
echo "Highest Element : " . $high;
echo "Lowest Element : " . $low;
?>
two files:
1) input.html
<HTML>
<BODY>
<center>
<form method=’post’ action=’xhi.php’ >
Please enter the alphabets:
<input type=’textbox’ length=30 name=’alpha’ />
<input type=’submit’ value=’submit’ />
</form>
</center>
</BODY>
</HTML>
2) xhi.php
<?php
$entered_val = explode(" " , $_POST['alpha']);
$total_char = 0;
$high = ‘a’;
$low = ‘z’;
//declaring array $arr
$arr = array(‘a’,'b’,'c’,'d’,'e’,
‘f’,'g’,'h’,'i’,'j’,'k’,'l’,'m’,'n’,'o’
,’p',’q',’r',’s',’t',’u',’v',’w',’x’
,’y',’z');
//associating value with alphabets a=1, b=2, z=26
// in $find
for($i=0;$i<count($arr);$i++){
$find[$arr[$i]]=$i+1;
}
for($i=0;$i<count($entered_val);$i++){
if($find[$entered_val[$i]]<$find[$low]){
$low = $entered_val[$i];
}
if($find[$entered_val[$i]]>$find[$high]){
$high = $entered_val[$i];
}
}
echo "Total number of elements : " . count($entered_val);
echo "Highest Element : " . $high;
echo "Lowest Element : " . $low;
?>
References :