Jump to content


Photo

String to remove html


  • Please log in to reply
8 replies to this topic

#1 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 24 February 2006 - 04:53 AM

I am using one tag in my header.tpl
<title>[main]</title>

The "main" content coming from index.php but it has html coding with it.....

I want to place in title tag only text and not te html coding.... Which are the tag which can help and get things fixed for me ...
One of my php project >> http://www.mumbaipropertysite.com

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 February 2006 - 05:00 AM

Look at the [a href=\"http://www.php.net/striptags\" target=\"_blank\"]striptags[/a]() function.

Ken

#3 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 24 February 2006 - 06:18 PM

Yes i have seen this before also.... but still i can't find what i want ?

See the [main] which is used 2 times in header.tpl And i want to use it as full code time in my body tag and only text in tilte tag here --- <title>[main]</title> when i doo this i get full html coding here please help to get only text in title....

The variable "main" is coming from index.php

please i'll be very thank full if you help me....
One of my php project >> http://www.mumbaipropertysite.com

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 February 2006 - 06:26 PM

This code:
<?php
$str = '<title>[main]</title>';
$stripped_str = strip_tags($str);
echo $stripped_str;
?>
prints "[main]"

Is this not what you want?

Ken

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 24 February 2006 - 06:35 PM

i think he may be asking how to parse out the "[main]" and replace it with a $main variable???

try something like this:
$string = "<title>[main]</title>\n";
$main = "My Title";
$string = preg_replace('|\[main\]|i', $main, $string);
echo $string;

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 24 February 2006 - 07:29 PM

[!--quoteo(post=349097:date=Feb 25 2006, 12:05 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 25 2006, 12:05 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
i think he may be asking how to parse out the "[main]" and replace it with a $main variable???

try something like this:
$string = "<title>[main]</title>\n";
$main = "My Title";
$string = preg_replace('|\[main\]|i', $main, $string);
echo $string;
[/quote]

Now as you said I placed this code in header.tpl but it's not working. It's .tpl file soo can i put php script in that file.

[main] has html code --- the code changes as click on different categoris or product.

<p class="main"><a href='/index.php'>Top</a>: <a href='/index.php/category/'>Category</a>: <a href='/index.php/category/product/'>Product</a>: </p>

Out of These i want text from the html code like "Top : Category : Product" soo that it can be displayed in Title. And Also in Body Part i want to used Full html code... and its there every thing fine with that.... Only need to Fix this Title Tag.

This [main] html code comes from index.php and now in header.tpl and want to use [main] 2 times one with the Full html code and one with only Text...



Please Help Me Its been soo many days i am solve this querry but ....

Please Guys Help Me
One of my php project >> http://www.mumbaipropertysite.com

#7 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 25 February 2006 - 04:11 AM

Please Help !
One of my php project >> http://www.mumbaipropertysite.com

#8 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 25 February 2006 - 09:17 AM

Hello,

As far as i understand u r trying to use the same variable [main] in title as well as body, but in title u want to show text without HTML. I would advice u to use two diffenet variables

In TPL,
<title>[maintitle]</title>
.
.
.
<body>[main]</body>

In PHP,

$maintitle = strip_tags($title);

assign both title and maintitle in template

hth
Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------

#9 smartguyin

smartguyin
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 26 February 2006 - 05:39 AM

[!--quoteo(post=349261:date=Feb 25 2006, 02:47 PM:name=samshel)--][div class=\'quotetop\']QUOTE(samshel @ Feb 25 2006, 02:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hello,

As far as i understand u r trying to use the same variable [main] in title as well as body, but in title u want to show text without HTML. I would advice u to use two diffenet variables

In TPL,
<title>[maintitle]</title>
.
.
.
<body>[main]</body>

In PHP,

$maintitle = strip_tags($title);

assign both title and maintitle in template

hth
[/quote]


THANK YOU "SAMSHEL"

It Worked... I am a PHP Learner i also tried this step but made a little mistake some where but after your suggestion i tried it again and it worked....

Atlast my Querry was solved completely Thank's

Thank's Phpfreaks.com thanks samshel and other guys !

One of my php project >> http://www.mumbaipropertysite.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users