如何将变量放在引号中

Sam*_*ley -1 php arrays variables quotes

我使用以下代码输出数组

$values = array();
foreach ($album as $a){
$values[] = $a['value'];
}

$string = implode(' or ', $values);

}
Run Code Online (Sandbox Code Playgroud)

返回

 1 or 2 or 3
Run Code Online (Sandbox Code Playgroud)

现在我怎么能把每个值都放到"",所以它看起来像

 "1" or "2" or "3"
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

65F*_*f05 7

if (!empty($values)) {
    $string = '"' . implode('" or "', $values) . '"';
} else {
    $string = 'What do you think you\'re doing!?';
}
Run Code Online (Sandbox Code Playgroud)

  • 不是我的意思,但我只是注意到"或"上的引号所以我错了,这将有效. (2认同)