My HTML form:
<form action="http://localhost/wordpress" id="search" method="get">
<input type="text" size="30" id="s" name="s" value="Type and hit enter" onfocus="javascript:this.value='';" onblur="javascript:this.value='Type and hit enter';"/>
<br/>
<input type="submit" value="Search"/>
</form>
My PHP script:
<div class="message">
You searched for:
<?php
$searchterms = explode(" ", $_GET["s"]);
foreach ($searchterms as $searchterm) {
$length = strlen($searchterm);
$searchterm = substr($searchterm, 0, $length-1); ?>
<span class="searchterm"><?php echo $searchterm." "; ?></span>
<?php } ?>
</div>
It cuts off the last alphabet AND leave the darn space behind ><