1 回答

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 關注
- 102 瀏覽
添加回答
舉報