2 Replies - 1021 Views - Last Post: 15 April 2011 - 10:10 AM Rate Topic: -----

#1 tex1820  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-April 11

Question: How to override font tag with CSS

Posted 15 April 2011 - 07:30 AM

Hi everyone!

I am currently working on a project where I need to make a php version of a flash program we have. We have some XML files with html in them that gets placed into the flash file so new modules can be created quickly. I am working on a php version that can be opened on devices that do not have flash. The issue I am having is font size. I need to ether override the font tags or removed them from the php version. Ideally the flash files and php would pull from the same XML files. I have tried over writing the html font tags with CSS with no success. Any ideas?

Thank you,
James S.

Is This A Good Question/Topic? 0
  • +

Replies To: Question: How to override font tag with CSS

#2 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: Question: How to override font tag with CSS

Posted 15 April 2011 - 08:06 AM

It's going to have to be with CSS because PHP has no control over how things are displayed. In your CSS you can always define a setting as ! important and it will generally override anything that is applied to the tag/class/id.

If your trying to strip the tags before submitting the information for the browser to display you can do it a couple of ways. str_replace would be the simplest solution. Regex solution would be more complicated but more robust.

edit:::: very very crude example using a regex pattern I found with Google.
<?php
	$str1 = "<font color=blue size=10>Blue Text</font>";
	$str2 = "<font color=blue>Blue Text</font>";
	$str3 = "<font>Blue Text</font>";

	echo "<h1>Before strip</h1><br/>";
	echo $str1 . "<br/>";
	echo $str2 . "<br/>";
	echo $str3 . "<br/>";
	echo str_repeat("_", 254) . "<br/>";
	
	$str1 = preg_replace('#</?font[^>]*>#is', '', $str1);
	$str2 = preg_replace('#</?font[^>]*>#is', '', $str2);
	$str3 = preg_replace('#</?font[^>]*>#is', '', $str3);
	
	echo "<h1>After strip</h1><br/>";
	echo $str1 . "<br/>";
	echo $str2 . "<br/>";
	echo $str3 . "<br/>";
?>


This post has been edited by RPGonzo: 15 April 2011 - 08:20 AM

Was This Post Helpful? 0
  • +
  • -

#3 tex1820  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-April 11

Re: Question: How to override font tag with CSS

Posted 15 April 2011 - 10:10 AM

I fixed it, thank you!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1