PHP PROGRAMS
DATAFETCH.HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> </title> </head> <body> <form method="post"action="nameShort.php"> <label>Enter name: </label> <input type="text" name="str1" id="str1"> <input type="submit" name="submit" id="Submit"> </form> </body> </html> nameShort.php <?php $str = $_REQUEST['str1']; // echo strlen($str); $fstr = array(); $ws = true; for($i=0; $i< strlen($str); $i++){ if($str[$i] == ' ') { $ws=true; } else if($str[$i]!= ' ' && $ws==true) { array_push($fstr,$str[$i]); $ws = false; } } for($i=0; $i<sizeof($fstr) ; $i++){ echo $fstr[$i]; }