Gossamer Forum
Home : General : Internet Technologies :

General PHP question - mktime()

Quote Reply
General PHP question - mktime()
Here is the code sample:

Code:
Code<?php
$dateA = '12-25-2003';
$dateB = '12-24-1999';

// convert to unix time stamps
$fooA = explode('-',$dateA);
$fooB = explode('-',$dateB);

$timestampA = mktime(0,0,0,$fooA[0],$fooA[1],$fooA[0]);
$timestampB = mktime(0,0,0,$fooB[0],$fooB[1],$fooB[0]);

if($timestampA > $timestampB)
{
echo $dateA . " is greater than B";
}
else{
echo $dateB . " is greater than A";
}
?>


My question is what do the [] represent in:

$timestampA = mktime(0,0,0,$fooA[0],$fooA[1],$fooA[0]);
Quote Reply
Re: [Unquick] General PHP question - mktime() In reply to
The[] represent a reference to the array. For example, if I use;

Code:
<?

$string = "this is a test string";
$exploded = explode(" ",$string);

for ($i = 0; $i <= 4; $i++) {
print "\$exploded[\$i] => " . $exploded[$i] . "<BR>";
}

?>

This would print something like;

$exploded[0] => this
$exploded[1] => is
$exploded[2] => a
$exploded[3] => test
$exploded[4] => string

As you can see, each word can be reference with the $array_name[] call. i.e $array_name[0].

Hope thats clear Smile

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Jun 2, 2003, 8:02 AM
Quote Reply
Re: [Andy] General PHP question - mktime() In reply to
Ok now I understand. So it would also be more correct to change the last array:

Code:
$timestampA = mktime(0,0,0,$fooA[0],$fooA[1],$fooA[2]);
$timestampB = mktime(0,0,0,$fooB[0],$fooB[1],$fooB[2]);


Perfect thanks.

Quote Reply
Re: [Unquick] General PHP question - mktime() In reply to
Yeah.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Unquick] General PHP question - mktime() In reply to
The [] essentially don't do anything, it is the number inside them that's important. It's a zero based index of the element.