|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Queston about splitting up something into an array
My queston is basicly, how do I take a string of characters and split them up into an array to where each character is a different element in the array. The reason I want to know (In case someone has a better idea of how to handle this altogether), is to take the datetime stamp in mysql and echo it back in a format that makes a little more sense as a date and time(rather then 20020829011035). I'm assuming to do that I'd have to have the entire thing broken into one array, but I have no idea how to do that. Then again there may be a ten times easier way that I know nothing about, I'm just a beginner afterall. So any suggestions would be great, thanks ahead of time. |
|
#2
|
|||
|
|||
|
RE: Queston about splitting up something into an array
well you can use the date function to format the time stamp, to be more friendly to read. either way the answer to your question:
|
|
#3
|
|||
|
|||
|
RE: Queston about splitting up something into an array
Well, a string is essentially an array. You can access it as such:
As to an easier way to reformat the date, I haven't had very much like getting mysql datetime fields to parse well through strtotime (which is needed to produce a unix timestamp for the date function). A better bet is to use the built in date and time functions to mysql. With those, you can format the date however you wish with your SQL query. Personally, I like storing dates in SQL as a unix timestamp...easier to work with in my opinion... |
|
#4
|
|||
|
|||
|
RE: Queston about splitting up something into an array
can you access it using $string[5]? i was under the impression that when referring to the elements of a string you needed to use curly brackets as follows $string{5}
:uhoh: |
|
#5
|
|||
|
|||
|
RE: Queston about splitting up something into an array
You are right...using the []'s is deprecated, but still works. The {}'s are the proper syntax....
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Queston about splitting up something into an array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|