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
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.