Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Reg Exp For HTML Tags


I'm have trouble with my regular expressions trying to grab the contents of html tags. Lets say i'm tyring to get what is between all my <td> tags. I wish to put all matches in an arry but its just not working for me. Well, I'm sure its working fine, i'm just not doing it right. I was trying this PHP Code:




View Complete Forum Thread with Replies

Related Forum Messages:
How Do You Prevent A User From Using Certain Tags Such As Html Or Vbscript Tags When Typing Names Etc In A Form?
how do you prevent a user from using certain tags such as html or vbscript tags when typing names etc in a form?

View Replies !
Using Strip Tags On Text Which Has Html Tags
I am using strip tags on text which has html tags, but for some reason it wont remove table tags (td, tr, etc.). How can I remove them?

View Replies !
PHP HTML Email Doesn't Format The Text Using The Html Tags
I had a PHP script that sent an html email from a Flash form. It was all working on a Windows based server. Then my server was switched to a Linux based one. It now sends the email, but has a lot of random characters and doesn't format the text using the html tags. Code:

View Replies !
HTML Email Using PHP Problem (Receive Html Tags)
When I send the html email, the only thing I receive is the tags (the
html codes basically). I want to be able to see the email like a html
page, what is wrong with my code? Here is a copy paste of it.

$HTML = "</html><body><img src='http://www.somewebsite.com/
someimage.jpg'></body></html>";

$headers = "From: $from
";
$headers .= "MIME-Version: 1.0
";
$boundary = uniqid("HTMLDEMO");
// Now we attach the HTML version

$headers .= "--$boundary
".
"Content-Type: text/html; charset=ISO-8859-1
".
"Content-Transfer-Encoding: base64

";

$headers .= chunk_split(base64_encode($HTML));

mail($to,$subject,"",$headers);

print "mail Sent<br>";

The email I receive has this as text:

</html><body><img src='http://www.somewebsite.com/someimage.jpg'></
body></html>

View Replies !
Html Tags Within Xml Tags
I'm trying to find a way to put a block of html within xml tags but it's not working. I think it's looking at the html tags as if they were xml tags. Here's an example of what I'd like to do.

<text>
<p>some text<br/>
some more text</p>
<p>another paragraph.</p>
</text>

I'd like the content between the <text></text>

tags to come through as a string to be passed along to the browser. Any suggestions with PHP parse?

View Replies !
HTML Tags...
Say if I wanted to allow people to use <strong> <em> <a href etc. when posting a comment on my story would PHP know that it's HTML and parse it or would I need to tell it somehow that there may be HTML coming in from the form before it stores it in the database? And when I query the database do I need to let it know it might be returning some raw HTML?

View Replies !
HTML Tags In XML
How can i use common html tags like <br> <p> in XML.


View Replies !
HTML Tags
I had to put a / after all my html input values right before the closing bracket to make my script work. Here's an example of what I mean. Code:

<input name="name" type="text" id="name" style="font-size:13;font-family:Arial, Helvetica, sans-serif;" size=45 />

View Replies !
Html Tags
how can i prevent that PHP Code:

<td>
<div>

<? $src = "";
if( isset( $srcimg ) ) $src = $srcimg;
if( isset( $id ) )  formatClickpath( $market, $id, $id, "", "", $src );
?>

</div>
</td>

View Replies !
Stripping HTML Tags
I have the following code at the beginning of a php page:

View Replies !
Checking HTML Tags
I'd like a system whereby certain HTML tags can be used but others can't. And the nice strip_tags function dealt with that rather nicely.

The problem is checking for tags left open. I've tried various things with regular expressions and found ways to detect when a tag is left open, but not how to do anything about it. Ideally, I'd like something that would remove any opening tags if there is already a tag of that sort open and add a closing tag at the end of the message if a tag isn't closed.

View Replies !
Cleaning Html Tags
somebody knows any way to put off all html tags from a file. I want to store cleaning pages for information purposes.

View Replies !
Php Mail With HTML Tags
I have written a php code to send the mail,Iam able to receive the mail but the mail is coming with all html Tags included like Code:

View Replies !
How Can I Replace All HTML Tags?
How can i replace all HTML Tags?

View Replies !
Best Way To Display HTML Tags?
I am trying to display the source of HTML files withing pages on my site. What is the best way to display the code so that it doesen't get parsed as HTML?

View Replies !
Problem With Html Tags
I need html tags in my forum pages to show up, but not to be active.
I have tried to change the tags to html equivalent code using php, but
still they are active.

How do I go about chaning them to non-active?

View Replies !
Get Data Between HTML Tags
I'm looking to get the baseball score between the html tags on yahoo and
create my own rows with just the data.

So far I have this code
-----------------------------------------------------------
$data = file_get_contents('http://sports.yahoo.com/');
list(, $data_split) = explode('<td width="50%" class="yspscores">', $data,
2);
list($data2, ) = explode('</a></td>', $data_split, 2);
$data2 = strip_tags($data2);
echo $data2;
-------------------------------------------------------

It gives me all the results but I want to do a loop that will find the first
row of scores create a new row and put the data in the new row then find the
next row of scores create another new row and insert the data and continue
that pattern to the end.



View Replies !
Removing HTML Tags
I am using ajax, so I am manipulate the text with either php(prefer) or javascript.
I have a text area where the user enters whatever. They click send and a 'js' function gets called and it calls my sendRequest function and sends over the data to my php file to be insert into my db.

What I want to do is remove any of the html/js tags I can. The only thing I want to keep is the spacing the user enters (line spacing).

My php file - I have tried many different ways, but none of them seem to work

$txt = $_GET['text'];

$stuff = array("","");
$txt = str_replace($stuff, "<br />");
echo strip_tags($txt, '<br />');

So using the code above if I enter:
<b>Test</b>

This is a test

The Results is:
TestThis is a test

I've tried another method using 'preg_match', but i am getting an error b/c of the function.

View Replies !
Htmlentities Except For Certain Html Tags
I have a script that retrieves a database record that's created by a user.  In that database record are bbcodes like [p].  My problem is that the records are for tutorials, so I need it to display the HTML as raw text, therefore I have to use htmlentities and even though I use str_replace to replace the bb tags, it still displays the <p> tags(previously [p]) as html.

I need the <p> tags to be translated into html so my layout works correctly.  Is there anyway to do this? Code:

View Replies !
Restricting Certain HTML Tags
I want to restrict users to only using certain html tags, such as a, b, i, and u, and for certain special purposes only embed.

View Replies !
Remove HTML Tags?
Basically what I am doing is making a blog of mine on my website AJAXable (and I copyright that word!). So I have it when I'm logged in all the script is enabled and I can edit the blog. Now when I click on the text it generates all the info in a textarea. However! I see my html tags. Now I'm pretty sure once I click on the submit button, it is going to store all those tags into the database. I do not want that ^_^

Is there a way with PHP or maybe Javascript to go through and delete these tags?

View Replies !
Closing HTML Tags
I have a user input form in which users who may be inexperienced with HTML are allowed to enter html tags. Is there a way with PHP to close any HTML tags entered by the user but not closed by them. For example:

the user inputs

"hello<BR>
<center> everybody!!!"

how do i dynamically close the center tag?

View Replies !
FCKEditor + HTML Tags
I want to use fckeditor to put content into my database. The code is working fine but I wasnt HTML tags to be inserted such as <p> but text is entered. Also I want img tag to be inserted but this is my code echoed. Code:

INSERT INTO test(test) values('content test

testing...

View Replies !
Getting Data From Html Tags
how to pull content from between a specified html tag and store it in a variable in php?
So for example, given this html string and the span tag and it's class is always consistent:

<span class="myClassName">W00t!</span>

How can i extract the "W00t!" part and store it in a variable ($myVariable)?

View Replies !
Echo Html Tags Or Not
Is the any advantage to this:

<?

echo "<input type="submit" value="Empty Cart" name="empty_cart">";
echo "<input type="submit" value="Update Cart" name="update_cart">";

?>

over this...

<input type="submit" value="Empty Cart" name="empty_cart">
<input type="submit" value="Update Cart" name="update_cart">

...or vice versa?

View Replies !
Limit Html IMG Tags In PHP
is there any function that can limit or remove more than 1 img tags in a string?

<?php
$string = "<img src=1> this is text <img src=2> <img src=3> here's some text <img src=4>";
echo limitImage($string);

function limitImage {
// Some function to do remove more than 1 img tags .

View Replies !
Storing All Html Tags
I have a tab delimited file of items for a shopping cart. Usually I dont have a problem with importing html tags. However this new project uses alot of tags including <table> tags. It seems to be creating a problem with my import. I am already using addslashes for ' but how do I deal with these html tags?

View Replies !
Substr Html Tags
I have allot of data that I want to cut to only 200 or so characters long and save to mysql. So I've done it using $blabla = substr($test,0,300)."..."; and save it successfully to mysql.

However my problem is that the text also has html tags that I wish to keep and not strip out. When I use the substr to cut the text, sometimes it will land on an html tag (for example <img src="as..) and cut it off halfway. Then when I view my output page to see the saved text in mysql, the output page messes up because of these incomplete html tags that where cut. Is there anyway to make an exception so if the substr lands on an html tag it will add the rest of it and then stop. So for example if it lands on <a href="http://asd.com"> it will keep going and save up to the </a>.

View Replies !
Data Within HTML Tags
Does anyone how to strip data out of html tags using regular expressions?

View Replies !
Specific HTML Tags
I have an HTML document that uses these opening tags

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />

If these tags are not in my file it won't show correctly, but whenever I save the HTML as .php and preview it, it gives me the following error:

Parse error: syntax error, unexpected T_STRING in c:Wampwww
ew_lbofixit.php on line 1

Is there any way to work around this?

View Replies !
Hiding Html Tags
i want to build a cms,in such a manner that the client who dont know php can update the content( can change text of left navbar,right navbar,center content by entering his own choice in a form of admin control panel) and upload images(banners,ads) etc...

how to do it.whether i have to store css,html in db or i create a separate .css file and implement it in php script.guide me which one i approach.if i store the css in db and retrieve the css,html divs in textarea from db,for updations the html tags should be hided but not ignored and display the 'text' only in textareas.so that he can delete or update those text..

View Replies !
Limit Html Tags In PHP
is there any function that can limit or remove more than 1 img tags in a string? PHP Code:

<?php
$string = "<img src=1> this is text <img src=2> <img src=3> here's some text <img src=4>";
echo limitImage($string);

function limitImage {
// Some function to do remove more than 1 img tags ..
}
?>

View Replies !
Html Tags Within XML File
I am trying to write a general function XML file parser, but it keeps choking when it finds embedded HTML within the text, for example:

<item>
<title>New PHP eBooks in PDF</title>
<description>
<p style="color: red">This entry was brought to you by <a
href="http://tutorials.lockergnome.com/">Lockergnome's
Tutorials</a></p><strong>New PDFs are Available!</strong>...
</description>

When I try to read this all I get is "p style=" (no quotes). Is there a function or routine I can use to read this as text so that it can be printed out in HTML?

View Replies !
Adding HTML Tags To CMS
I have written some php which allows a user to update their website, using a backoffice and saving the info into a mySQL database.

I would like the user to be able to insert HTML tags around areas of text e.g <h1> </h1> or <b> </b> etc. Is there a way to do this in php? I'm not even sure what to look for when I'm googling it!!

View Replies !
How To Get Html Tags From A Database ?
I have a database where people themself put a profilname into.

I have just had a user who called his profil HisName<something>
When this was written in my profil name list it only said HisName. Probably because the browser thought that <something> was html coding.

So how can I get a name like that from the database without any mistakes by the browser.
Is there some special way I should get the data from the database, or ??

I looked in MyPhpAdmin and here his name was HisName<something> so it is put in the database OK, it's when I get the name in the browser it can't get it right.

View Replies !
My Form Vs. HTML Tags
I have a form to post content to my site that supports bbcode, but if wanted, anyone can introduce html tags.

The only thing I need is something to cancel the html tags, to do not accept < and > as html delimiters, but as normal characters.

View Replies !
How Do You Allow Html Tags In The Mail?
I know how to send a regular email with only text using the mail function, but how do you allow html tags in the mail? I've tried using tags such as <b>, etc. but they dont work.

View Replies !
Strip MS Html Tags
I have got a string with contains several <p class=MsoFootnoteText style="MARGIN: 0in 0in 0pt; mso-pagination: widow-orphan"> tags and I need to replace them with simple <p>. The problem is that those tags appear then user copy Word document into textarea instead of typing the text in.

View Replies !
Adding / To HTML Tags
I've seen that when using some HTML tags in a php echo statement that you should add a space, then a forward slash before the closing tag. For example:

<br> becomes <br />

Can someone tell me the reason this is needed, and whether it applies to ALL HTML tags? For example, what about these:

<a href="page.htm" />link</a />
<font class="big" />text</font />
<form />
<input type="submit" value="Pay" name="submit" />
</form />

When (and why) is it needed, and when (if ever, not)?

View Replies !
Replacement Of HTML Tags
I'm trying to replace every second <TR> with <tr class="Body2">. PHP Code:

function update_content_CHL(&$CHL_content) {    // use this to modify the HTML tags etc   
    $CHL_content = str_replace('<TABLE>','<TABLE Width="100%">',$CHL_content);   
    $CHL_content = str_replace(' in Rankings','',$CHL_content);   
    $CHL_content = str_replace('Rank','R',$CHL_content);   
    $CHL_content = str_replace('(','<br>(',$CHL_content);   
    $CHL_content = str_replace(' Week','',$CHL_content);   
    //$CHL_content = str_replace('<TR>','<TR class="Body2">',$CHL_content);   
$instance = 1;    
for ($i=0; $i<=strlen($CHL_content); $i++) {    
    if (substr($CHL_content, $i, 4) == "<TR>") {    
        if ($instance % 2 == 0) {    
            substr_replace($CHL_content, "<tr class="Body2">", $i, 4);    
        }    
        $instance++;    
    }    
}

View Replies !
Inserting Html Tags Into Php
I have a list of news items that I would like separated by a line break. Whenever I insert a <p> or a <br /> the news items all get surrounded by quotes and seperate the items by more than a line break. Here is my php:

while ($article = mysql_fetch_array($articles)) {

$id = $article['id'];
$articletext = $article['LEFT(articletext, 120)'];

// If the article text is 120 characters long, add "..." to the end of it
// to indicate that it is actually longer. strlen() returns string length!
if (strlen($articletext) == 120) {
$articletext .= "...";
}.

View Replies !
HTML Tags In Database
I'm using WYSIWYG editor to add some contents into database. When i add the contents in the database they are displayed the same way as when i write them in the editor, however i want them to be displayed with html tags. e.g i don't want them saved in the db

as 'text' but as '<p>text</p>'.
$text = htmlspecialchars($text)

before adding contents into the db should be working.

View Replies !
Number Of Html Tags
If I have some html that looks like this:

<p>This is a paragraph:</p>

<ul>
<li>Bullet one</li>
<li>Bullet two</li>
<li>Bullet three</li>
</ul>

Is there a way to count the number of <li> tags? So that it returns 3.

View Replies !
Removing Attributes From Html Tags
I want to build a class which will return a stripped version of variable containing HTML tags.

In my constructor i will use strip_tags to get rid of the unwanted tags in the variable.

After that i'll call a method cleanup() which has to do the hard work.

Lets say i fill an array with values containing attributes like Onclick Onmouseover Style in my constuctor.

I will allow de <a> tag to be used, but i want to strip the tag from attributes mentioned above.

View Replies !
Removing Empty HTML Tags
Long story short:

Converting word files to readable HTML (approx 1200 docs).

Got it going good, have one problem left:
Due to the difference between hard and soft carriage returns, sometimes end up with <p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> and I need to get rid of these. There are differring numbers of non-printing characters and spaces between the p tags.

I am convinced that a regular expression will do this but so far have not found one.

So basically what I need is to remove any paragraphs that contain no printable characters.

View Replies !
Strip Html Tags ATTRIBUTES With Reg Exp
I want to strip html attribute within a tag. e.g.:

<td class="blah" colspan="2" bgcolor="#ffffff">blah</td>

And I want to leave the 'colspan="2"' intact. result after stripping with reg exp:

<td colspan="2">blah</td>

View Replies !
Textarea - HTML Tags Problem
The following is my php code for a form to subit data from a textbox


echo"<td colspan="3" valign="top"><textarea wrap="virtual" cols="50" rows="8" name="addr" >Type address here.</textarea></td>";

But, when the data submitted to my database, it included all the html tag such as <div>, &nbsp;...so how to I just submit plain text to my database?

View Replies !
Extracting Specified HTML Tags With Regex
I have a regex problem, spent about 7 hours on this now, but I don't find
the answer in the manual and googling, though I think this must have been
discussed before.

I try to simply extract the title and meta tags of a valid HTML page as an
array:

function extract_html($filename)
{
$ret = array();
// put file into string
$contents = file_get_contents($filename);
// title
$p = preg_match_all('<(title|TITLE)>(.+)</(title|TITLE)>', $contents,
$matches);
if ($p > 0) {
$ret[] = $matches[0][0];
}
// metatags
$p = preg_match_all("<(meta|META)(.+)>", $contents, $matches);
if ($p > 0) {
for ($i=0; $i<$p; $i++) {
$ret[] = $matches[0][$i];
}
}
return $ret;
}

What happens is:
- The title part gets no match
- The meta matches are correct, but miss the opening <

The examples I have seen in the manual all seem to have no problem with <
and > in the patterns. I don't know where to look and also don't understand
all parts of the regex section.

View Replies !
Preg_replace Words Only - Not In Html-tags
I'm having a hard time replacing words "only", that is, do not replace occurences of the word in an HTML-tag. Here's some code: PHP Code:

View Replies !
RegX To Grab Everything Outside HTML Tags
i have some 350 $terms in the dictionary to check against the $rf. PHP Code:

View Replies !
Eregi (html Anchor Tags)
I need to get all the html anchor tags from a string. heres my eregi line: PHP Code:

View Replies !
Text Data Containing HTML Tags?
I am working on a content system. But cannot seem to figure out how to display text that has html formatting tags included. I use a form and the TEXTAREA to have users submit text. I save it to a MySQL db.

I want the user to be able to use html tags such as <B></B>, but when I display what was saved, the HTML tags do not function. I have read about addslashes(), and removeslashes(), but am not sure I fully understand them. Should I be trying these?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved