Re: string to array??

From: Date: Wed, 16 Jan 2002 10:55:39 +0000
Subject: Re: string to array??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80898@lists.php.net to get a copy of this message
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" <Sandeep.Murphy@oni.pt> To: <php-general@lists.php.net> 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#80898) next »