数组xArray
(
    [0] => ,title='测试上窜',titlepic='/ukinfo/d/file/house/other/2011-04-18/small97207890060e54843633227589c40db11303110292.jpg',smalltext='大师傅撒法撒法斯柯达发啊的',batype='住宅买卖',expire='2011-06-17',intro=''
    [3] => ,contact='戴先生',email='[email protected]',phone='01133435800',qq='17589636'
    [4] => 1
)想要判断数组x[0]中titlepic是否有值。
将x[0]用逗号explode之后得到的数组Array
(
    [0] => 
    [1] => title='测试上窜'
    [2] => titlepic='/ukinfo/d/file/house/other/2011-04-18/small97207890060e54843633227589c40db11303110292.jpg'
    [3] => smalltext='大师傅撒法撒法斯柯达发啊的'
    [4] => batype='住宅买卖'
    [5] => expire='2011-06-17'
    [6] => intro=''
)
请问如何判断其中titlepic是否有值呢?即获取titlepic的''之间的值

解决方案 »

  1.   

    if(x[0][2] != ''){
        echo '有值';
    }
      

  2.   

    $y = explode(x[0],'=');
    if (y[1] == "''") echo '空值';
      

  3.   


    $str = "titlepic='/ukinfo/d/file/house/other/2011-04-18/small97207890060e54843633227589c40db11303110292.jpg'";
    $newstr = explode('=', $str);//再分一次
    var_dump($newstr[1] == "''");//查看第二个元素值是否等于两个单眼号
      

  4.   

    strpos("titlepic=''",$x[3])这样应该可以,但不好,再想想。。
      

  5.   


    这个不行吧?
    eval($x[0][2]);//注意:前面是否有$titlepic这个变量,有的话会覆盖
    if (!empty($titlepic)) echo '有值';
      

  6.   

    $x = array(
       0 => ",title='测试上窜',titlepic='/ukinfo/d/file/house/other/2011-04-18/small97207890060e54843633227589c40db11303110292.jpg',smalltext='大师傅撒法撒法斯柯达发啊的',batype='住宅买卖',expire='2011-06-17',intro=''",
      3 => ",contact='戴先生',email='[email protected]',phone='01133435800',qq='17589636'",
      4 => 1,
    );parse_str(str_replace(",", "&", $x[0]), $ar);if(! empty($ar['title'])) echo '有值';
      

  7.   

    print_r($x[0]['titlepic']);直接获取‘’中的值
      

  8.   


    为什么我用你的方法得出来的加了反斜杠呢?
    Array
    (
        [title] => \'dsfafdasfda\'
        [titlepic] => \'/ukinfo/d/file/house/other/2011-04-19/smalld43d1cf05dde58234ff3d37e837fb6191303179196.jpg\'
        [smalltext] => \'sdfasfsafa\'
        [batype] => \'住宅买卖\'
        [expire] => \'2011-06-18\'
        [intro] => \'\'
    )
    $artp=stripslashes($ar[titlepic]);
    echo $artp; //无论$ar[titlepic]是否有值都显示为''怎么取[titlepic]?