$str ="3,8,9,10,11,";
$array = explode(",", $str);
foreach($array AS $_key=>$value){ 
  if($value==3){
     echo "你好";
  }elseif($value==11){
     echo "我好";   
  }else{
    echo "都好";
  }
}

解决方案 »

  1.   

    $show.="$value";这个你做甚?
      

  2.   

    估计是想把数字变成对应文字<?php
    echo '<meta http-equiv="content-type" content="text/html;charset=utf-8">';$str ="3,8,9,10,11,";
    $array = explode(",", $str);
    foreach($array AS $_key=>$value){ 
        echo show($value);
    }function show($v){
        if($v==3){
            return '你好 ';
        }elseif($v==11){
            return '我好 ';
        }else{
            return '都好 ';
        }
    }
    ?>你好 都好 都好 都好 我好 都好