Creating An Array From Sentence In Php

RegisterLogin
Creating An Array From Sentence In Php
Post Description: Learning About Creating An Array From Sentence In Php Is Easy We Wll Show You
Tags: Creating, An, Array, From, Sentence, In, Php
This Post Was Posted On Oct 30, 2009 By Webune Tutorials #2673
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!!!!
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
crazy
#3670 1
wow, this is exactly what i was looking for how to make an array of an sentence in php and i found it. i never thought something like this would be available.

you are all jerks, even tho i learned from this, everyone here is fools
Mar 30, 2010 Reply Report abuse
©2011 Webune Forums - Mon Dec 19, 2011 2:26 pm
Powered by: Webune Forums V3