Hi There.

You should use this function:

split -- split string into array by regular expression

array split (string pattern, string string [, int limit])


So, to split a string ( e.g. a sentence ) so that each word in the string is
an element of the array do something like this

<?php
    $sMyString = 'The cat sat on the mat.';
    $aMyArray = split ( ' ', $sMyString );
?>

This will return:

$aMyArray[0] == 'The';
$aMyArray[1] == 'cat'; ... etc

"If limit is set, the returned array will contain a maximum of limit
elements with the last element containing the whole rest of string. "

Cheers

Scott

----- Original Message -----
From: "Sandeep Murphy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 17, 2002 12:41 PM
Subject: [PHP] string to array??


> hi,
>
> can i convert a string to an array?? if so how shud the syntax read??
>
> Thnx,
>
> sands
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to