• Notice regarding image hosts and attachments. See here.

PHP Array Help

Soldato
Joined
28 Apr 2011
Posts
16,273
Location
Barnet, London
Hi, I've been dabbling in PHP for months now so I know I should know this, but can anyone confirm I would be doing this right if I made an array like this -

Code:
$item = array(
"date" => $date,
"name" => $name,
"comment" => $comment
);

Then added it to an array like this -

Code:
array_push($items, $item);

Would I then access the comments for example, like this -

Code:
$thisComment = $items[$x]['comment'];

And how would I sort the items by 'date', given the date format goes yyyy-mm-dd, so should work as a straight forward sort?

Thanks!
 
Back
Top Bottom