1 回答
![?](http://img1.sycdn.imooc.com/533e50ed0001cc5b02000200-100-100.jpg)
TA贡献1858条经验 获得超8个赞
欢迎来到堆栈溢出,阿比德!
您能否添加当前输出和预期输出,也许还可以添加错误消息?因为我看到你使用调用时间传递引用,这在5.4中被删除了。().update_comment(&$comment)
我试图运行代码并采用它,我看到它在更改后似乎工作正常。下面是一个声明性和命令式方法的示例。
function update_comments($comments)
{
if (!empty($comments) && is_array($comments)) {
foreach ($comments as $idx => $comment) {
$comments[$idx] = update_comment($comment);
}
}
return $comments;
}
并在这里作为声明性示例
function update_comments($comments)
{
if (!empty($comments) && is_array($comments)) {
$comments = array_map(function ($comment) {
return update_comment($comment);
}, $comments);
}
return $comments;
}
下面是我如何使用您的代码的示例。您还可以在这里使用特定的PHP版本进行修补:http://sandbox.onlinephpfunctions.com/code/10e616237c0c75c8e3520bdf5866040231879cde
$comments = update_comments([
['comment' => 'This is my #1 comment.'],
['comment' => 'This is my #2 comment.']
]);
print_r($comments);
// Array
// (
// [0] => Array (
// [comment] => This is my <a href="#">#1</a> comment.
// )
//
// [1] => Array (
// [comment] => This is my <a href="#">#2</a> comment.
// )
//
// )
如果这有帮助,或者您的问题仍然存在,请告诉我。preg_replace()
- 1 回答
- 0 关注
- 83 浏览
添加回答
举报