|
-
Oct 9th, 2006, 07:10 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Split / Explode
I have looked at php.net for this, with little result.
I want to seperate one string into an array, here is what i want to achieve.
PHP Code:
$blah = "css:syntax:copyright";
// Split up, using : as the string pattern, i want these to go into an array
Loop array
// My code
end;
No considering i havnt done arrays, or looping an array to the last instance i will look this up, and one know how to get the string split into an array? And if pos, how the array will loop?
Cheers
-
Oct 9th, 2006, 10:40 AM
#2
Re: Split / Explode
You haven't looked very hard, apparently. The function you want is called explode().
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 9th, 2006, 04:14 PM
#3
Re: Split / Explode
Split and Explode both do the same thing, though Split I believe is just a shortcut and calls to explode anyway.
syntax is: explode(delimiter, string, limit)
where limit is the maximum number of positions you want in the array you're making. it's optional, and by default it will just split everything unless specified otherwise.
-
Oct 9th, 2006, 04:37 PM
#4
Re: Split / Explode
Wrong. split() splits on a regular expression, explode() on a simple string. Thus, explode() is faster, and split() can hit you unexpectedly if your split string contains regex characters.
This is a mistake that is easily made, because the reverse functions, join() and implode(), are in fact aliases for the same function, since you can't join on a regular expression.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 10th, 2006, 03:43 AM
#5
Thread Starter
Frenzied Member
Re: Split / Explode
Ah! I have used switch > for each and a switch statement.
Right well im sorted, cheers guys (Y) spot on
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|