我有这样的foreach循环。
if ( is_object($res_two)) {
if($res_two->num_rows() == 0) {
echo "No Records Found";}
else if( $res_two->num_rows() > 0) {
foreach ($res_two->result() as $row ) {
echo $row->js_id."\t". $row->designation."\t".$row->full_name."\t".$row->location."\t".$row->graduated_in."\t";
$mail2 = $row->email;
echo $mail2 ;
?> <a href="<?php echo base_url("uploads/".$row->resume."")?>">Download Resume</a> <br/><br/> <?php
}
}
}
?>
现在我要提取$ mail2详细信息。但是,在代码中回显$ mail2只给出一个值而不是数组(如果foreach循环迭代,它应该有多个值?)。
如何在代码外获取$ mail2的多个值?
答案 0 :(得分:1)
<?php
if (is_object($res_two)) {
if ($res_two->num_rows() == 0) {
echo "No Records Found";
} else if ($res_two->num_rows() > 0) {
foreach ($res_two->result() as $row) {
echo $row->js_id . "\t" . $row->designation . "\t" . $row->full_name . "\t" . $row->location . "\t" . $row->graduated_in . "\t";
$mail2[] = $row->email;
?> <a href="<?php echo base_url("uploads/" . $row->resume . "") ?>">Download Resume</a> <br/><br/> <?php
}
}
}
print_r($mail2);
?>