下面我有一个文字输入:
'<input type=\"text\" name=\"indivoptions\" class=\"options\" id=\"answer".$option."\" name=\"answerName[$option]\" value=\"$option\" />'
现在我希望在文本输入中爆炸后显示每个$option
,而不是一般的字符串输出,但是我将上面的代码放在下面的代码中?
$options = explode('-', $option);
if(count($options) > 1) {
$start = array_shift($options);
$end = array_shift($options);
do {
$options[] = $start;
}while(++$start <= $end);
}
当前代码:
function ExpandOptionType($option) {
$options = explode('-', $option);
foreach($options as $answers) {
$answers = '<p><input type=\"checkbox\" name=\"anstype\" class=\"answers\" id=\"answer".$option."\" name=\"answerName[$option]\" value=\"$option\" />$option</p>';
}
if(count($options) > 1) {
$start = array_shift($options);
$end = array_shift($options);
do {
$options[] = $start;
}while(++$start <= $end);
}
else{
$options = explode(' or ', $option);
}
return implode(" ", $options);
}
答案 0 :(得分:0)
$options = explode('-', $option);
foreach($options as $indivOption) {
// do something with each option ($indivOption)
}