好的,這裏的想法是讓代碼將SF_追加到數組中的所有鍵名。 我把我的數組(它是一個對象的一部分),翻轉它,添加SF_,並翻轉它。這個php代碼有什麼問題?
某處在我失去了一些領域的過程中...
這裏是我開始:
object(stdClass)[12]
public 'Affiliate_Code__c' => string 'XX-TXUJC3' (length=9)
public 'AltEmail__c' => string '[email protected]' (length=22)
public 'City' => string 'Mobile' (length=6)
public 'Email' => string '[email protected]' (length=22)
public 'Fax__c' => string '251-300-1234' (length=12)
public 'FirstName' => string 'Benny' (length=5)
public 'LastName' => string 'Butler' (length=6)
public 'Phone' => string '251-300-3530' (length=12)
public 'PostalCode' => string '36606' (length=5)
public 'State' => string 'AL' (length=2)
public 'Street' => string '851 E I-65 Service Rd' (length=21)
public 'test1__c' => float 1
array
'SF_Affiliate_Code__c' => string 'XX-TXUJC3' (length=9)
'SF_Email' => string '[email protected]' (length=22)
'SF_City' => string 'Mobile' (length=6)
'SF_Fax__c' => string '251-300-1234' (length=12)
'SF_FirstName' => string 'Benny' (length=5)
'SF_LastName' => string 'Butler' (length=6)
'SF_Phone' => string '251-300-3530' (length=12)
'SF_PostalCode' => int 36606
'SF_State' => string 'AL' (length=2)
'SF_Street' => string '851 E I-65 Service Rd' (length=21)
這裏是我的代碼:
$response = $mySforceConnection->query(($query));
foreach ($response->records as $SF) {
}
var_dump($SF);
$SF = array_flip($SF);
foreach ($SF as $key => $value){
$SF[$key] = 'SF_'.$value;
}
$SF = array_flip($SF);
echo "<pre>";
var_dump($SF);
echo "</pre>";
extract($SF);
任何想法? 我是任何類型的面向對象編程的新手,我確信這與它有關。 我很愚蠢的我必須做的:
foreach ($response->records as $SF) { }
,因爲我不知道怎麼去數組任何其他方式。 幫助! 謝謝!如你所說,
爲什麼不是在foreach使用$ SF的代碼?沒有意義......或錯字? – 2009-09-22 21:14:21