Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试用 PHP 制作 LaTeX 解析器,并且我想删除某些尾随的新行(\\符号)。
\\
但问题是,如果它在其他所有内容之前,我只想删除新行(双反斜杠)。
就像,我想删除\\以下示例中的第一个:
\\3+6=9
但不是这个\\:
3+\\6=9
我怎样才能用 PHP 做到这一点?
采用trim
trim
$arr = trim('your_string','\\');
工作示例http://codepad.viper-7.com/OaYxWG
在 php 中使用修剪
i.e., trim("string","\\");
您可以执行以下操作
$a = "\\aaaaa"; if (substr($a, 0, 1) === '\\') { echo trim($a,'\\'); }
它将回显“aaaaa”。希望这可以帮助