Styles2304 Posted June 17, 2008 Share Posted June 17, 2008 I got a chunk of code from effigy and I've been trying to modify it to work with something new and I'm having trouble. Here is the code I'm trying to preg_match_all: <div id="yw-forecast" > <em>Current conditions as of 9:53 am EDT</em> <h3>Fair</h3> <dl> <dt>Feels Like:<\/dt><dd>67°<\/dd> <dt>Barometer:<\/dt><dd>30.08 in and rising<\/dd> <dt>Humidity:<\/dt><dd>57%<\/dd> <dt>Visibility:<\/dt><dd>10 mi<\/dd> <dt>Dewpoint:<\/dt><dd>51°<\/dd> <dt>Wind:<\/dt><dd>NNW 7 mph<\/dd> <dt>Sunrise:<\/dt><dd>6:22 am<\/dd> <dt>Sunset:</dt><dd>9:19 pm</dd> </dl> <div class="forecast-temp"> <h3>67°</h3> <p>High: 78° Low: 55°</p> <ul> <li>» <a class="action" href="#text">Detailed Forecast</a></li> <li>» <a class=action href="http://weather.yahoo.com/climo/USIN0660_f.html">Records & Averages</A> <li>» <a class=action href="http://us.rd.yahoo.com/evt=37752/*http://widgets.yahoo.com/widgets/yahoo-weather">Get Yahoo! Weather on your desktop</a></li> </ul> </div> <div class="forecast-icon" style="background:url('http://l.yimg.com/us.yimg.com/i/us/nws/weather/gr/34d.png'); _background-image/* */: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://l.yimg.com/us.yimg.com/i/us/nws/weather/gr/34d.png', sizingMethod='crop'); "></div> and here's what I'm actually trying to retrieve: Note: *** = I have no F'n clue how to write the regex to retrieve this section. $patterns = array( '/(?<=weatherTempText">)(?P<feels_like>\d+°)/', '/(?<=weatherText">)(?P<current_barometer>***/', '/(?<=weatherText">)(?P<current_humidity>\d+%)/', '/(?<=weatherText">)(?P<current_visibility>***/', '/(?<=weatherText">)(?P<current_dewpoint>***;)/', '/(?<=weatherText">)(?P<current_wind>***/', '/(?<=weatherText">)(?P<current_temp>***/', '/(?<=weatherText">)(?P<current_high>***/', '/(?<=weatherText">)(?P<current_low>***/', '/(?<=weatherimage">)(?P<current_image>***/', ); Just to give whoever is looking at this their bearings, "current_image" is "http://l.yimg.com/us.yimg.com/i/us/nws/weather/gr/34d.png" and all of that will stay the same except for the filename (34d.png). So yeah . . . I'm probably biting off WAY more than I can chew because I just can't seem to wrap my brain around regex. Link to comment https://forums.phpfreaks.com/topic/110593-dont-quite-understand-this-bit-of-code/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.