Solarpitch Posted March 26, 2011 Share Posted March 26, 2011 Hey Guys, I'm querying a database that is going to return a html page. In this page I'm going to define content areas with a class. eg: <div class="category"></div> Anywhere I have this class in the html code, I want to dynamically insert a link into it. So when I retrieve the code from the database, I need the code to check for this tag (class="category") and add a standard link (<a href="..">Add new Category</a>) Not 100% sure whats the most efficient way to go about this. Link to comment https://forums.phpfreaks.com/topic/231793-adding-a-link-dynamically/ Share on other sites More sharing options...
Solarpitch Posted March 26, 2011 Author Share Posted March 26, 2011 Thi sworked actually $string = $code; $expression = "</head>"; $insertvalue = " Hello"; $string=preg_replace("|$expression|",$expression.$insertvalue,$string,1); Link to comment https://forums.phpfreaks.com/topic/231793-adding-a-link-dynamically/#findComment-1192611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.