acidglitter Posted May 27, 2007 Share Posted May 27, 2007 It might be called parsing but I'm not sure.. If I had a line that looked like this.. $string = "This text is <b id="one">bold</b> and so is <b id="two">this text</b>"; And this is what I want.. $words = "<b id="two">this text</b>"; What would I do to only select that part of the $string? Quote Link to comment https://forums.phpfreaks.com/topic/53167-parsing/ Share on other sites More sharing options...
Psycho Posted May 27, 2007 Share Posted May 27, 2007 You need to be more specific. What is the rule you will use to determine which text to extract? Are you looking for the text that is enclosed in a tag with id="two"? Without any additional information, you could solve the above example with $words = substr($string, 44); But, I don't think that is really what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/53167-parsing/#findComment-262756 Share on other sites More sharing options...
paul2463 Posted May 27, 2007 Share Posted May 27, 2007 how will the string manifest itself??? allways as above??? if so you can use <a href="http://uk2.php.net/substr"> substr() </a> or you can use regex Quote Link to comment https://forums.phpfreaks.com/topic/53167-parsing/#findComment-262757 Share on other sites More sharing options...
acidglitter Posted May 27, 2007 Author Share Posted May 27, 2007 You need to be more specific. What is the rule you will use to determine which text to extract? Are you looking for the text that is enclosed in a tag with id="two"? Yea thats what I meant. Text inside b id="two" Quote Link to comment https://forums.phpfreaks.com/topic/53167-parsing/#findComment-262823 Share on other sites More sharing options...
gabeg Posted May 27, 2007 Share Posted May 27, 2007 I would suggest using regex to pull out the part of the string you want Quote Link to comment https://forums.phpfreaks.com/topic/53167-parsing/#findComment-262827 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.