我有问题回应一个数组.
$test = 'one two three four';
$arr = explode(' ', $test);
echo '<br />+'.$arr[0].' +(>'.$arr[1].' <'.$arr[2].'';
Run Code Online (Sandbox Code Playgroud)
它停止在$ arr [1]回显,我需要在mysql中进行特殊查询.
我需要实现的是:
('+one +(>two <three)
Run Code Online (Sandbox Code Playgroud)
另外,我想知道如何使用$ arr [2]中的"<"字符来〜.简而言之,我要实现的目标是:
('+one +(>two <three <four ... <infinite)
Run Code Online (Sandbox Code Playgroud)
它不会停止回显,浏览器只会错误<标记开头的字符并相应地采取行动.
如果要显示此输出,则应htmlspecialchars首先调用它.否则(例如,对于查询)不需要特殊处理.
对于你的上一个问题:你会做类似的事情
$test = 'one two three four five';
$arr = explode(' ', $test);
$out = '+'.$arr[0].' +(>'.$arr[1].' <'.implode(' <', array_slice($arr, 2)).')';
echo htmlspecialchars($out); // only for echoing!
Run Code Online (Sandbox Code Playgroud)