2 回答
TA贡献1862条经验 获得超7个赞
你正在$rets从你的getNames函数中返回,但没有使用它。你只需要使用这个变量$rets而不是全局变量。
if(isset($_GET['search'])){
//echo 'Search</br>';
} elseif(isset($_GET['display_this'])) {
$rets = getNames(); //The $rets will hold the value returned by your function getName().
if( !empty ( $rets ) ) {
echo '</br><b>Your selections so far :</b></br>';
echo $rets;
}
}
您可以从getNamesMethod 中删除 echo 语句。
function getNames() {
$rets = '';
if(isset($_GET['choices']) and !empty($_GET['choices'])){
foreach($_GET['choices'] as $selected){
$rets .= $selected.' -- ';
}
}
return $rets;
}
TA贡献1796条经验 获得超4个赞
您应该在函数内部使数组全局化,因此最重要的是:
$all_authors = array();
在底部:
function getNames() {
global $all_authors;
// Do the rest of the stuff
}
- 2 回答
- 0 关注
- 172 浏览
添加回答
举报