- Forums
- PHP
- Creating An Array From Sentence In Php
Learning About Creating An Array From Sentence In Php Is Easy We Wll Show You [2057], Last Updated: Mon Jun 24, 2024
Webune Tutorials
Fri Oct 30, 2009
1 Comments
526 Visits
welcome to webune support forums
we have dedicated server with php.
today we are going to show you about creating an array from a sentence.
lets say we have this sentence:
Webune Has Excellent Dedicated Servers
as you can see, i have six words in that sentence, we can make 6 elements in an array using php.
you can use this code:
First, lets create our string:
$foo = 'Webune Has Excellent Dedicated Servers';
ok, now that we have our string, we can break it up into elements with the explode() function in php like this:
PHP CODE:
<?php
$foo = 'Webune Has Excellent Dedicated Servers';
$foo = explode(' ',$foo);
echo '<pre>';
print_r($foo);
echo '</pre>';
?>
OUTPUT:
Array
(
[0] => Webune
[1] => Has
[2] => Excellent
[3] => Dedicated
[4] => Servers
)
TRY IT!!!!
https://www.webune.com/forums/creating-an-array-from-sentence-in-php.html