Jump to content

Replace <br> to a full stop


Help!php

Recommended Posts

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";
		}

Link to comment
https://forums.phpfreaks.com/topic/259049-replace-to-a-full-stop/
Share on other sites

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?

$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..

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.