2011-10-11 45 views
0

我有一個數組,看起來像這樣,循環通過陣列,奇怪的輸出

Array 
(
    [candidate_id] => 1 
    [first_name] => Simon 
    [surname] => Ainley 
    [gender] => male 
    [talent] => presenter 
    [DOB] => 1987-06-12 
    [Location] => Huddersfield 
    [height] => 6' 3" 
    [eyes] => blue 
    [hair] => brown 
    [hair_length] => short 
    [accents] => Native english 
    [training] => none 
    [unions] => Actors guild 
    [date_created] => 2011-10-11 00:00:00 
) 

然而,當我穿上之後,

<?php foreach ($results as $k => $v) : ?> 
    <?php print_r($v); ?> 
<?php endforeach; ?> 

使用此我得到的輸出,

1 S A m p 1 H 6 b b s N n A 2 
+0

這絕對不是你的陣列:http://ideone.com/KdsMV –

+0

@WesleyMurch: - 或 - 不是代碼:) – hakre

+0

喲用簡單的回聲試過嗎? – punit

回答

1

當你嘗試回顯一個實際上是字符串的數組元素時,會發生這種情況。例如。

$string = "hello"; 
echo $string[1]; // echos "e" 

確保的$結果的結構是什麼,你認爲這是你正在使用的print_r()在正確的變量。另外:String access and modification by character Docs