CitizenErased Posted December 14, 2011 Share Posted December 14, 2011 Hi i'm trying to get out a sub string from multiple pages where i'm using a start point string that looks like this "(integer)" where "integer is different every time. Is there any way I can tell it that its just an integer there so if its "(3)" on one page and "(10)" on another page it will start from the same spot? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 14, 2011 Share Posted December 14, 2011 Huh? Quote Link to comment Share on other sites More sharing options...
Phpfr3ak Posted December 14, 2011 Share Posted December 14, 2011 Yea, can you phrase this better, as currently makes no sense. can possibly help then. Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 14, 2011 Share Posted December 14, 2011 Sounds like you are parsing some text and are wanting to use the "(NUMBER)" as a reference point. You will likely want to use regular expression (preg_match() I'm assuming) You could either use a regular expression to extract out the content you want or, if you want to use string functions but just need to know the position, you can use a regex to find the "(NUMBER)" value and use that value in your string functions. Quote Link to comment Share on other sites More sharing options...
CitizenErased Posted December 14, 2011 Author Share Posted December 14, 2011 Yeah it didn't sound right when i was writing it $Start = "(3)"; $End = "string"; $StartPos = strpos($content, $Start); $EndPos = strpos($content, $End); $SubString = substr($content, $StartPos, $EndPos - $StartPos ); where "3" in "(3)" will be changing to a different integer from page to page Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 14, 2011 Share Posted December 14, 2011 Well, you can dynamically find the start text using a regex and use your current logic //Find first instance of ( decimal ) preg_match("#\(\d+\)#", $content, $startText); $Start = $startText[0]; Or you can replace all of that logic with a single regular expression to return all the text that you need. I can provide that as well but need to know whether you need the start and end text in your results. Quote Link to comment 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.