Re: Novice question - Please Help

From: Date: Wed, 30 Jan 2002 13:54:18 +0000
Subject: Re: Novice question - Please Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-82733@lists.php.net to get a copy of this message
On Wed, 30 Jan 2002 12:10:14 +0000, you wrote: >Could someone please email me and tell me how to split a string into >different arrays <? /* this is our start string */ $str = "this:is:a:test:string"; /* split accepts a regular expression and a string, and returns an array */ /* we could also use preg_split() or explode() */ $arr = split(':', $str); /* for each element of $arr */ for ($i = 0; $i < sizeof($arr); $i++) { /* display element */ echo($arr[$i]); echo('<br>'); } /* I know it's weird, but use sizeof() for arrays, and strlen() for strings */ echo('$arr has ' . sizeof($arr) . ' elements<br>'); echo('$str has ' . strlen($str) . ' characters<br>'); ?> >and save what they were split on? Not sure what this means. >Also I cant get the sizeof function to work no matter what syntax i use, i >think ive tried them all, do you have to include a library or something in >your program to make it work? If the above doesn't work, then maybe there's something wrong with your install. djo

« previous php.general (#82733) next »