你能帮我用一个函数来替换字符串,如下所示:
该字符串the boo[k|ks] [is|are] on the table
将输出the book is on the table
或the books are on the table
根据一个参数。
<?php
$unformated_str = "the boo[k|ks] [is|are] on the table";
$plural = true;
echo formatstr($unformated_str, $plural);
?>
输出:
the books are on the table
原谅我糟糕的英语。我希望我的问题足够清楚。