Jump to content

liquidskin

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by liquidskin

  1. I feel like I'm getting close... // separate array values by comma and store for ( $i = 0; $i < $rowcount; $i += 1) { $string1 = $precipData[$i]; $string2 = $hourData[$i]; $explode1[$i] = explode(",", $string1); //precip $explode2[$i] = explode(",", $string2); //hours $countHolder = $explode1[$i]; $countValuesInArray = count($countHolder); // loop through # of values in array for ( $j = 0; $j < $countValuesInArray; $j += 1) { $bodyBuild[$j] = $explode2[$i][$j]. "\n". $explode1[$i][$j]; } } $comma_separated = implode(",", $bodyBuild); echo $comma_separated; this outputs " 9pm 40,10pm 40,11pm 40,12am 40,1am 40,2am 40,3am 40,4am 40,5am 40,6am 40,7am 40,8am 20,9am 20" which is the last row in the db. I need to store this for each row, plus I need the linebreak.
  2. I need to loop through my db and create strings from 2 columns on my db. data in column1 is '22,33,33,33,25,25,25,14,14,14,14,14,14' data in column2 is '11am,12pm,1pm,2pm,3pm,4pm,5pm,6pm,7pm,8pm,9pm,10pm, 11pm' the end result I need is a string such as: $body= "11am, 22 <line break> 12pm, 33 <line break> ...... If anyone has any examples of something like this or can get me started it would be much appreciated.
  3. hi all, I decided to dump the rand() method on the URL for file_get_contents and to try cURL. However, I'm having the same issue. <?php class CA_HTTP { public static function get_contents($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); ob_start(); curl_exec ($ch); curl_close ($ch); return ob_get_clean(); } } ?> $xml = CA_HTTP::get_contents($url); I was under the impression that CURLOPT_FRESH_CONNECT would do the trick. Anyone know why I'm receiving old data?
  4. finally got it. $precip_array = element_set('value', $precip,$content_only = true); now I'm only getting 2 chars on the string, which I was able to convert to int and compare. thanks for getting me thinking, ialsoagree
  5. I'm extracting from an XML file. The 17 characters is the following: <value>77</value> which I'm doing the following to with functions from xml_regex.php $precip = value_in('probability-of-precipitation', $xml);$precip_array = element_set('value', $precip);
  6. still see 17 chars. also tried $compareValue = (int)trim($precip_array[0]); to no avail
  7. Hi all, Im so stuck on this! Cant figure out a solution... $precip_array[0] has a value of "80" in it as a string. I need to compare it to an integer. echo (int)$precip_array[0] returns a "0". Ive also tried adding a 0 but that results in the same. I did a var_dump on $precip_array[0] which returns string(17) "80" I think 17 signifies the length of the string, but I only see 2 digits when I echo this. Any help is much appreciated.
  8. Hi all, I'm working on a concept and am confused how to handle the next phase. In short, I have a PHP file that accepts a users zip code in the URL and performs some logic to return some values. What I want to do is store user's email addresses with some preferences such as the time they would wish to receive an email if the PHP returns 'yes'. Because this logic is location based, some users will receive an email at 6AM, some at 7AM, some wont receive one at all. Is what I'm looking to do possible? I think I'd have to use cron jobs to kick this off, but I'm a little unsure of the general structure on this. If anyone has any examples or similiar experience with this sort of thing, I'd be super interested in hearing about it. Thanks!
  9. i tried once more and it seems to work this way: $url = 'http://forecast.weather.gov/MapClick.php?lat=40.65160&lon=-74.34420&FcstType=digitalDWML&'.rand(1,1000); thanks!
  10. Hi all, I should first mention I'm not much of a coder, I'm using PHP to create a custom weather solution for myself. Basically am pulling XML from weather.gov and working with the data. So far, so good. I'm getting the data I want displayed correctly, but noticed when I refresh the page I sometimes receive old data. (From the past hour, two hours, etc.) I figured this was cached info and I'm trying to figure out how to clear that out. This is how I'm accessing the XML: $url = 'http://forecast.weather.gov/MapClick.php?lat=40.65160&lon=-74.34420&FcstType=digitalDWML'; $xml = file_get_contents($url); I did some research and tried the following headers, but that doesnt seem to work: <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ?> Also tried appending a random number onto the $url, (as per a forum question/response somewhere) but that didn't work. Anyone suggestions would be great. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.