Tonic-_- Posted January 5, 2011 Share Posted January 5, 2011 This kind of has me in lala land as this is very strange... I'm going through a list of dates in such format. [earned] => Array ( [0] => 2010-07-14T11:26:09Z [1] => 2010-07-31T06:35:14Z [2] => 2010-07-14T11:25:55Z [3] => 2010-07-31T06:29:43Z [4] => 2010-07-31T06:31:47Z [5] => 2010-07-14T11:26:17Z ) Everything is setup correctly but the first offset of an array comes back blank. Like so. - 2010-07-14T11:26:09Z 1280558114 - 2010-07-31T06:35:14Z 1279106755 - 2010-07-14T11:25:55Z 1280557783 - 2010-07-31T06:29:43Z 1280557907 - 2010-07-31T06:31:47Z 1279106777 - 2010-07-14T11:26:17Z Now if I manually use strtotime on just 2010-07-14T11:26:09Z I get the value I seek (1279106769) My foreach setup... foreach($trophy['earned'] as $key2=>$value2) { echo strtotime($trophy['earned'][$key2]) . " - " . $trophy['earned'][$key2] . "<br />"; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/ Share on other sites More sharing options...
Kieran Menor Posted January 5, 2011 Share Posted January 5, 2011 Is that really all you have in the foreach? Any chance you could post the whole script? Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155175 Share on other sites More sharing options...
Tonic-_- Posted January 5, 2011 Author Share Posted January 5, 2011 I can't post the entire script due to legal concerns but that's pretty much everything in the foreach. I noticed this because I am inserting information into my database. The $trophy variable contains an array like so.. Array ( [id] => Array ( [0] => 1 [1] => 4 [2] => 5 [3] => 7 [4] => 9 [5] => 11 ) [earned] => Array ( [0] => 2010-07-14T11:26:09Z [1] => 2010-07-31T06:35:14Z [2] => 2010-07-14T11:25:55Z [3] => 2010-07-31T06:29:43Z [4] => 2010-07-31T06:31:47Z [5] => 2010-07-14T11:26:17Z ) ) The id array works fine and inserts the proper data but the strtotime for the Timestamp does not work properly for the first offset of the array, so I came to the conclusion that it has to be with strtotime it's self as the foreach works the way I want for everything but the strtotime in the foreach does not work on the timestamp. I ruled out the possibility of it being a issue with the timestamp its self just by using strtotime on the value. It's really bothering me.. Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155176 Share on other sites More sharing options...
Kieran Menor Posted January 5, 2011 Share Posted January 5, 2011 Legal concerns? :-\ Seriously, though, I think the problem lies elsewhere in the code. Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155181 Share on other sites More sharing options...
Tonic-_- Posted January 5, 2011 Author Share Posted January 5, 2011 I'm starting to lean towards that.. I even just did function blahblah($data) { return strtotime($data); } and the first offset still comes back blank :S I'll just poke around.. *EDIT* Seem's to be something with that first offset... Can't figure out what but thanks anyways. Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155183 Share on other sites More sharing options...
Kieran Menor Posted January 5, 2011 Share Posted January 5, 2011 You could start by posting the entire contents of that specific foreach? Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155185 Share on other sites More sharing options...
Tonic-_- Posted January 5, 2011 Author Share Posted January 5, 2011 Oh Boy, I found the issue within my preg_match. Thanks for trying to help anyways although I just can't post that part of the script. Bai Bai Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155189 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2011 Share Posted January 5, 2011 @Tonic-_-, almost everything that can be done in a web application has been done countless times. Nothing you are doing in one specific portion of your code is so unique that we haven't already seen it dozens of times. If you cannot troubleshoot what your code is doing and you aren't, can't, or won't post the actual portion of your code responsible for producing the symptom, I don't know just what help you were expecting to get from a programming help forum. Short answer: Don't waste the forum's time with coding problems that cannot be answered because the problem is in code that you did not bother to show in your post. Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155195 Share on other sites More sharing options...
Tonic-_- Posted January 5, 2011 Author Share Posted January 5, 2011 Sorry... The legal concern was server keys to a high-level area for SCEA/Sony. I didn't want to cause any troubles if the keys were posted here. I just assumed the issue had to be within that small foreach but it was something else. Quote Link to comment https://forums.phpfreaks.com/topic/223474-strtotime-issue-with-foreach/#findComment-1155202 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.