- Forums
- PHP
- How To Divide String To Letters Php
This Page Contains information about How To Divide String To Letters Php By Webune Tutorials in category PHP with 0 Replies. [2043], Last Updated: Mon Jun 24, 2024
Webune Tutorials
Thu Oct 08, 2009
0 Comments
455 Visits
hi, welcome to Webune.com Web Hosting Support. We provide free support to all our valued customers. in this short tutorial we will show you how you can split a string into letters using an array in php.
Do you have PHP on your website? if you dont, sign up with one of our economical web hosting packages which inlocude PHP and MySQL so you can start doing this tutoril live on your site.
so lets say i have a string like this:
$foo = "webune";
and i want to divide the whole webune word into individual values. well you can, using PHP str_split() function.
so lets continue with our example here, this is how we would divide the $foo string into separate values.
if you have windows, i am using windows XP, you should have notepad. open a blank notepad and copy and paste the following code:
<?php
######################################################
# DISTRIBUTED UNDER GLP/UGN COPY RIGHTS BY WEBUNE.COM
######################################################
?>
<h1>How to divide string to letters php</h1>
By <a href="http://www.webune.com">Webune.com</a>
<hr />
<form action="" method="post">
Enter a Word you want to split: <input type="text" name="foo" / >
<input type="submit" name="submit" value="submit" / >
</form>
<?php
if(isset($_POST['foo'])){
$foo = str_split($_POST['foo']);
echo '<pre style="color:blue">';
print_r($foo);
echo '</pre>';
echo 'for more cool tutorials visit us at <a href="http://www.webune.com">Webune.com</a>';
}
?>
now save as.. "word-split.php"
[NOTE: be sure to include the quotes when saving as to be sure notepad saves the file as a php file]
now upload to your website which has PHP, then point the browser to word-split.php where you uploaded.
and give it a try, you will see when you enter a word, it will divide it into sections using an array.
hope that helps