Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am trying to replace specific string with html tags. I tried a lot but none of them worked.

Example: This is testing string with \section*{string} this tag.

I tried below mentioned code,but couldn't to get the output

$str = str_replace(array('\\section*{', '}'), array('<title>', '</title>'), $str);

and this too,

$str=str_replace('\\section*{','<title>',$str);
$str=str_replace('}','</title>',$str);



Expected output: This is testing string with <title>string</title> this tag.
Posted
Updated 30-Oct-14 3:28am
v3

1 solution

Try this:
PHP
<?php
$str ="This is testing string with \section*{string} this tag.";
$str = str_replace('\\section*{','&lt;title&gt;',$str);
$str = str_replace('}','&lt;/title&gt;',$str);
echo $str;
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900