using an array to create vars.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

using an array to create vars.

Post by pinehead18 »

I have a date information stored in a sql database. That looks like this 01/18/2004

I want to use an array to pull that date and seperate those 01 18 2004 into their own variables. Seperated by the / what array function do i use to do this?

Thank you for your tyime and help,.
Anthony
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$array = explode('/', $date);
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Just of curiousity, what would that function return? Would it be something like

Code: Select all

$array[1] = 01;
$array[2] = 18;
$array[3] = 2004;
??

Thanks!
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Yes, except minus one from each number.

Arrays start at 0, not 1, so it'd have values in $array[0], [1], and [2].
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Oh, okay, got it. :) Thanks.
Post Reply