generate functionSun, 12 Feb 2023

write a joomla function to find the first h2 tag in the content and insert a html content before this tag

function put_stuff_before_h2_tag($content) { $html_tag = '<h2>'; $html_tag_at_position = strpos($content, $html_tag); $content_before_tag = substr($content, 0, $html_tag_at_position); $content_after_tag = substr($content, $html_tag_at_position); $content = $content_before_tag . '<div>Stuff I want to put in before the h2 tag</div>' . $content_after_tag; return $content; }

Questions about programming?Chat with your personal AI assistant