十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
如何在php代碼中輸出數(shù)學公式?針對這個問題,今天小編總結(jié)這篇代碼文字解析結(jié)合的文章,希望幫助更多同學解決這個問題。
作為一家“創(chuàng)意+整合+營銷”的成都網(wǎng)站建設機構(gòu),我們在業(yè)內(nèi)良好的客戶口碑。成都創(chuàng)新互聯(lián)公司提供從前期的網(wǎng)站品牌分析策劃、網(wǎng)站設計、網(wǎng)站設計制作、網(wǎng)站制作、創(chuàng)意表現(xiàn)、網(wǎng)頁制作、系統(tǒng)開發(fā)以及后續(xù)網(wǎng)站營銷運營等一系列服務,幫助企業(yè)打造創(chuàng)新的互聯(lián)網(wǎng)品牌經(jīng)營模式與有效的網(wǎng)絡營銷方法,創(chuàng)造更大的價值。

使用google的接口顯示數(shù)學公式
單行公式
多行公式

$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 ';
$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.='
';
}
if($count>0){
echo $str_new;
}else{
echo $str;
}看完上訴內(nèi)容,你們掌握在php代碼中輸出數(shù)學公式的方法了嗎?如果想了解更多相關內(nèi)容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!