Help!php Posted March 16, 2012 Share Posted March 16, 2012 I am trying to get information from a website and these information are seperated by <br> Samsung ML-3310ND <br> AC Cable (UK) <br> CD/DVD (including Software/ Utilities/ Drivers and User Manuals) <br> Setup Guide <br> Black Toner Cartridge 2000 pages When I import this to the database it becomes Samsung ML-3310NDAC Cable (UK)CD/DVD (including Software/ Utilities/ Drivers and User Manuals) Setup GuideBlack Toner Cartridge 2000 pages How would I get it exactly how it looks. so it doesnt print in one paragraph. this is the code I am using.. $inbox = $html->find( "#ctl00_placeholderMain_pnlInTheBox" ); if ( isset( $inbox[ 0 ] ) ) { // Tidy it up - remove commas and weird Word chars $box = strip_tags( $inbox[0] ); //$box = substr( $box, strpos( $box, ";" ) + 1 ); $box = strpos($box, ';') !== FALSE ? substr( $box, strpos( $box, ";" ) + 1 ) : $box; $box = str_replace("", "<br>", $box ); } else { $box = "0"; } Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/ Share on other sites More sharing options...
trq Posted March 16, 2012 Share Posted March 16, 2012 I am trying to get information from a website and these information are seperated by <br> Samsung ML-3310ND <br> AC Cable (UK) <br> CD/DVD (including Software/ Utilities/ Drivers and User Manuals) <br> Setup Guide <br> Black Toner Cartridge 2000 pages When I import this to the database it becomes Samsung ML-3310NDAC Cable (UK)CD/DVD (including Software/ Utilities/ Drivers and User Manuals) Setup GuideBlack Toner Cartridge 2000 pages And what exactly are you doing to make that happen? Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328007 Share on other sites More sharing options...
Help!php Posted March 16, 2012 Author Share Posted March 16, 2012 I am trying to replace <br> with a full stop. or <br> $box = str_replace('<br>', ".", $box ); or $box = str_replace('<br>', '<br>', $box ); but its not working... Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328010 Share on other sites More sharing options...
stijn0713 Posted March 16, 2012 Share Posted March 16, 2012 </ br> ? Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328011 Share on other sites More sharing options...
trq Posted March 16, 2012 Share Posted March 16, 2012 No where in your code have you tried either of those two things. You still haven't explained where (or why) you strip the <br> tags before inserting this data into your database. Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328013 Share on other sites More sharing options...
Help!php Posted March 16, 2012 Author Share Posted March 16, 2012 $inbox = $html->find( "#ctl00_placeholderMain_pnlInTheBox" ); if ( isset( $inbox[ 0 ] ) ) { // Tidy it up - remove commas and weird Word chars $box = strip_tags( $inbox[0] ); //$box = substr( $box, strpos( $box, ";" ) + 1 ); $box = strpos($box, ';') !== FALSE ? substr( $box, strpos( $box, ";" ) + 1 ) : $box; $box = str_replace("</ br>", ".", $box ); // this is where I am trying to replace the <br> with a full stop } else { $box = "0"; } I am not striping <br>. when I try to get it from the website. All the information is in one paragraph.. Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328016 Share on other sites More sharing options...
trq Posted March 16, 2012 Share Posted March 16, 2012 I am not striping <br> Then how do you explain the fact that it is missing from your data in the database? (hint, your using strip_tags on the data) As for this: $box = str_replace("</ br>", ".", $box ); // this is where I am trying to replace the <br> with a full stop That tries to replace </ br> with . there is no </ br> in your data. Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328021 Share on other sites More sharing options...
Help!php Posted March 16, 2012 Author Share Posted March 16, 2012 Yep I just found it. I am using box = strip_tags( $inbox[0] ); to strip everything so the <br> get stripped. I have removed that but now i am getting something like <div id="ctl00_placeholderMain_pnlInTheBox" class="tabitem"> <p> HP LaserJet 9050 printer<br/> Power cord<br/> Parallel cable<br/> HP LaserJet Q8543X Smart print cartridge<br/> Printer documentation<br/> Printer software CD<br/> Control panel overlay<br/> Face-up output bin<br/> Two 500-sheet input tray<br/> 100 Sheet Multipurpose Tray<br/> HP JetDirect Fast</p> </div> I dont want ]<div id="ctl00_placeholderMain_pnlInTheBox" class="tabitem"> <p> and </p> </div>[/code] What would I need to do in order to remove the div Quote Link to comment https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/#findComment-1328030 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.