smartguyin Posted February 24, 2006 Share Posted February 24, 2006 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 ... Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/ Share on other sites More sharing options...
kenrbnsn Posted February 24, 2006 Share Posted February 24, 2006 Look at the [a href=\"http://www.php.net/striptags\" target=\"_blank\"]striptags[/a]() function.Ken Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12329 Share on other sites More sharing options...
smartguyin Posted February 24, 2006 Author Share Posted February 24, 2006 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.phpplease i'll be very thank full if you help me.... Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12364 Share on other sites More sharing options...
kenrbnsn Posted February 24, 2006 Share Posted February 24, 2006 This code:[code]<?php$str = '<title>[main]</title>';$stripped_str = strip_tags($str);echo $stripped_str;?>[/code]prints "[b][main][/b]"Is this not what you want?Ken Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12366 Share on other sites More sharing options...
obsidian Posted February 24, 2006 Share Posted February 24, 2006 i think he may be asking how to parse out the "[main]" and replace it with a $main variable???try something like this:[code]$string = "<title>[main]</title>\n";$main = "My Title";$string = preg_replace('|\[main\]|i', $main, $string);echo $string;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12368 Share on other sites More sharing options...
smartguyin Posted February 24, 2006 Author Share Posted February 24, 2006 [!--quoteo(post=349097:date=Feb 25 2006, 12:05 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Feb 25 2006, 12:05 AM) [snapback]349097[/snapback][/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:[code]$string = "<title>[main]</title>\n";$main = "My Title";$string = preg_replace('|\[main\]|i', $main, $string);echo $string;[/code][/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 Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12371 Share on other sites More sharing options...
smartguyin Posted February 25, 2006 Author Share Posted February 25, 2006 Please Help ! Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12399 Share on other sites More sharing options...
samshel Posted February 25, 2006 Share Posted February 25, 2006 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 variablesIn TPL,<title>[maintitle]</title>...<body>[main]</body>In PHP,$maintitle = strip_tags($title);assign both title and maintitle in templatehth Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12408 Share on other sites More sharing options...
smartguyin Posted February 26, 2006 Author Share Posted February 26, 2006 [!--quoteo(post=349261:date=Feb 25 2006, 02:47 PM:name=samshel)--][div class=\'quotetop\']QUOTE(samshel @ Feb 25 2006, 02:47 PM) [snapback]349261[/snapback][/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 variablesIn TPL,<title>[maintitle]</title>...<body>[main]</body>In PHP,$maintitle = strip_tags($title);assign both title and maintitle in templatehth[/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'sThank's Phpfreaks.com thanks samshel and other guys ! Quote Link to comment https://forums.phpfreaks.com/topic/3566-string-to-remove-html/#findComment-12534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.