如何在php代碼中輸出數(shù)學(xué)公式

如何在php代碼中輸出數(shù)學(xué)公式?針對這個問題,今天小編總結(jié)這篇代碼文字解析結(jié)合的文章,希望幫助更多同學(xué)解決這個問題。     

作為一家“創(chuàng)意+整合+營銷”的成都網(wǎng)站建設(shè)機(jī)構(gòu),我們在業(yè)內(nèi)良好的客戶口碑。成都創(chuàng)新互聯(lián)公司提供從前期的網(wǎng)站品牌分析策劃、網(wǎng)站設(shè)計、網(wǎng)站設(shè)計制作、網(wǎng)站制作、創(chuàng)意表現(xiàn)、網(wǎng)頁制作、系統(tǒng)開發(fā)以及后續(xù)網(wǎng)站營銷運(yùn)營等一系列服務(wù),幫助企業(yè)打造創(chuàng)新的互聯(lián)網(wǎng)品牌經(jīng)營模式與有效的網(wǎng)絡(luò)營銷方法,創(chuàng)造更大的價值。

如何在php代碼中輸出數(shù)學(xué)公式

使用google的接口顯示數(shù)學(xué)公式

單行公式 

<img src="http://latex.codecogs.com/gif.latex?$(a_{1})^2+(a_{3})^2\geq%202(a_{2})^2$" />

多行公式

<img src="http://latex.codecogs.com/gif.latex?$$%20\left\{%20\begin{aligned}%200\leq%20x\leq%202%20\\%200\leq%20y\leq%202\\%20\end{aligned}%20\right.%20$$" />

如何在php代碼中輸出數(shù)學(xué)公式

$str='$$ \left\{
                   \begin{aligned}
                   x^2+3y^2=3 \\
                   y=k(x-1)\\
                   \end{aligned}
                   \right.
        $$';
    //將$$轉(zhuǎn)化為$$
    $str=str_replace("$$", "$", $str);
    // dd($str);
    $pattern='/\$(.*)\$/Us';//只能識別$$  $$
    preg_match_all($pattern,$str,$matches);
    $arr_split=preg_split($pattern,$str);
    //dd($arr_split);
    // dd($matches);
    $count=count($matches[1]);
    $str_new="";
    for($i=0;$i<count($matches[1]);$i++){
        //$arr_replace[]='<img src="http://latex.codecogs.com/gif.latex?'.$matches[1][$i].'" />';
        $matches_str=$matches[1][$i];
        // dd($str);
        //先把\\n轉(zhuǎn)換成\\\n
        $matches_str=str_replace("\\\n", "\\\\\n", $matches_str);
        // dd($matches_str);
        $matches_str=preg_replace('/\s*/', '', $matches_str);
        // dd($matches_str);
        $str_new.=$arr_split[$i];
        $str_new.='<img src="http://latex.codecogs.com/gif.latex?'.$matches_str.'" />';
    }
    if($count>0){
        echo $str_new;
    }else{
        echo $str;
    }

看完上訴內(nèi)容,你們掌握在php代碼中輸出數(shù)學(xué)公式的方法了嗎?如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

本文題目:如何在php代碼中輸出數(shù)學(xué)公式
轉(zhuǎn)載來源:http://muchs.cn/article30/ipgdso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、動態(tài)網(wǎng)站、微信小程序云服務(wù)器域名注冊、品牌網(wǎng)站設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司