How To Count And Break A Word Into An Array In Php Tutorial Guide

RegisterLogin
How To Count And Break A Word Into An Array In Php Tutorial Guide
Post Description: How To Count And Break A Word Into An Array In Php Tutorial Guide
Tags: How, To, Count, And, Break, A, Word, Into, An, Array, In, Php, Tutorial, Guide
This Post Was Posted On Feb 29, 2008 By web hosting #1261

this step by step tutorial provided free by Webune Hosting



breaking down a word or a string into individual strings is possible through php. you can lear from this simple and easy to use tutorial



this is a simple script we wrote to show you how you can do this,



this is a rough and raw script, nothing fancy, just enough to show you how you can break down a word using an array and a loop then disaply each letter from that word



to see this script in action just copy and paste the code below into notepad and then copy and paste into notepad or any text editor, then save it as word-splitter.php and upload to your php website, then open it with your browser and you can test it out for yourself, you will break down whatever word you enter into separate arrays each containing their own string for each word





<img src="http://webune.com/images/headers/default_logo.jpg">

<h1>Breaking down a word into an array by webune.com</h1><hr>

<?

if(isset($_REQUEST['Submit']))

{

# FORM HAS BEEN SUMBITTED



$str = $_POST['name'];

$num_char = strlen($str);

echo "You entered: <strong>".$str."</strong><br>";

echo "Number of Characters found: <strong>".$num_char."</strong><br>";

$num_char = $num_char - 1;

echo '<br><table>';

for($counter =0; $counter <= $num_char; $counter++)

{

echo '<tr><td>Letter '.$counter.': </td><td><strong>'.$str[$counter],'</strong></td></tr>';



}

echo '</table><br>';

echo '<strong><a href="http://www.webune.com">Continue >></a></strong>';

}

else

{

# FORM HAS NOT BEEN SUBMITTED

?>


 


<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">

Name: <input name="name" type="text" maxlength="15">

<input type="submit" name="Submit" value="Submit">

</form>

<?

}

?>

<hr>

<div align="center">PHP Webhosting at <a href="http://www.webune.com">www.webune.com</a></div>



Please remember that you will need PHP for this script to work, if you dont' have PHP on your wesbite, we can help you. or you can visit www.webune.com and signup with PHP hosting with them. we always recommend webune.com because they have excellent service and are always willing to help

Chuck
#1688 1
the colors on this site are killing my eyes..
Sep 16, 2007 Reply Report abuse
©2011 Webune Forums - Sun Dec 18, 2011 5:29 pm
Powered by: Webune Forums V3