$sql = "select fieldname from tablename"; $Results = mysql_query($sql, $DBLink); $Row = mysql_fetch_array($Results); $fieldname = $Row["fieldname"]; $Date = explode("-", $fieldname); $Year = $Date[2];
> -----Original Message----- > From: Andre Dubuc [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, June 12, 2002 4:11 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Extracting from an Array > > > I have a db field, type varchar, that is actually a 'date' > string formatted > as dd-mm-YYYY. I used type 'varchar' (rather than type > 'date') since I had to > accomplish other things with it. > > Now, however, I do need to extract the Year (the last four > digits in the > array). I've tried to access the array $_SESSION['expiry'] > but I don't know > how to explode this array to extract all characters in last > item after the > last separator : i.e. '-YYYY'. I've used "-" as the > separator, but I just > get the first number of the last part of the array, i.e.: '-Y'. > > Is there a way of extracting all characters in that array? > > I've tried a bunch of combinations, but I obviously don't > understand the > basic mechanics of array manipulation or 'slicing'. If > someone could point me > to a good resource, or explain what I'm doing wrong, I would > greatly any > assistance. > > Tia, > Andre > **************************************************************************** This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php