Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Searchs de string for latex code (between $$) and returns link with the corresponding image if found
- *
- */
- function replaceLatex($text){
- $match = preg_match_all('(\$[^\$]*\$)',$text,$latexTextArray);
- //if there isnt latex in the text
- if ($match==0) return $text;
- $replacedText=$text;
- foreach ($latexTextArray[0] as &$latexText){
- //Remove the $ signs
- $result = substr($latexText,1);
- $result = substr($result,0,-1);
- //We replace the text for the latex img
- $replacedText = str_replace($latexText, "<img src=\"http://latex.codecogs.com/gif.latex?".$result."\" border=\"0\"/> ", $replacedText);
- }
- return $replacedText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement