denoteone Posted March 20, 2009 Share Posted March 20, 2009 I have a function that opens a web page and then builds and array by scrubbing the page. i dont understand how the array is looking for the data can anyone help me with this? $quote_data = array( "Name" => array("pattern" => "/<h1>([^<]+?)<\/h1>/", "value" => "N/A"), "Last" => array("pattern" => "/:.+?<big><b>(.+?)<\/b><\/big>/", "value" => "N/A"), "Time" => array("pattern" => "/Trade Time:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "Date" => array("pattern" => "", "value" => "N/A"), "Change" => array("pattern" => "/Change:<\/td><td.+?alt=\"(.+?)\">.+?>(.+?)<\/b>.+?>\s+(.+?)<\/b>/", "value" => "N/A"), "PercentageChange" => array("pattern" => "", "value" => "N/A"), "PreviousClose" => array("pattern" => "/Prev Close:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "Open" => array("pattern" => "/Open:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "High" => array("pattern" => "/Day's Range:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "Low" => array("pattern" => "", "value" => "N/A"), "AnnRange" => array("pattern" => "/52wk Range:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "Volume" => array("pattern" => "/Volume:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "MktCap" => array("pattern" => "/Market Cap:<\/td><td.+?>(.+?)<\/td>/", "value" => "N/A"), "P-E" => array("pattern" => "/P\/E .+?<td.+?>(.+?)<\/td>/", "value" => "N/A"), "Earns" => array("pattern" => "/EPS .+?<td.+?>(.+?)<\/td>/", "value" => "N/A") ); Link to comment https://forums.phpfreaks.com/topic/150346-building-and-array/ Share on other sites More sharing options...
sloth456 Posted March 20, 2009 Share Posted March 20, 2009 There's a lot of regex pattern matches in that array, but no command that actually parses out the data. Could you please post the full code. I imagine, somewhere further down is a preg_match command. Link to comment https://forums.phpfreaks.com/topic/150346-building-and-array/#findComment-789618 Share on other sites More sharing options...
denoteone Posted March 20, 2009 Author Share Posted March 20, 2009 let me try this differently my RegEx is /:.+?<big><b>(.+?)<\/b><\/big>/ the string it is searching is <big><b><span id="yfs_l10_^dji">7,403.58</span></b></big> what it getting is <span id="yfs_l10_^dji">7416.41</span> i need the Regex to get only what is between the span.... ??? I do not need the span tag in there... Link to comment https://forums.phpfreaks.com/topic/150346-building-and-array/#findComment-789651 Share on other sites More sharing options...
sloth456 Posted March 20, 2009 Share Posted March 20, 2009 ok, well this is a very inelegant way to do it, but this is how I normally parse info out of stuff try /:.+?<big><b><span.*?>(.*?)</span><\/b><\/big>/ I use .*? as a way of saying "skip over whatever is here" and (.*?) for "grab whatever is here" Hope that helps. Link to comment https://forums.phpfreaks.com/topic/150346-building-and-array/#findComment-789754 Share on other sites More sharing options...
denoteone Posted March 20, 2009 Author Share Posted March 20, 2009 I will give it a try thanks sloth Link to comment https://forums.phpfreaks.com/topic/150346-building-and-array/#findComment-789767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.