var_dump显示以下内容,我想循环显示此内容并希望显示所有电子邮件
array(85) {
["attributes"]=>
array(2) {
["type"]=>
string(7) "Contact"
["url"]=>
string(56) "/services/data/v20.0/sobjects/Contact/000002HQRBYAA5"
}
["Id"]=>
string(18) "0030002HQRBYAA5"
["IsDeleted"]=>
bool(false)
["Email"]=>
string(28) "t@stics.com"
}
array(85) {
["attributes"]=>
array(2) {
["type"]=>
string(7) "Contact"
["url"]=>
string(56) "/services/data/v20.0/sobjects/Contact/0002HQRBTAA5"
}
["Id"]=>
string(18) "0000002HQRBTAA5"
["IsDeleted"]=>
bool(false)
["Email"]=>
string(35) "test@gmail.com"
}
我在PHP中尝试的是这个
$accID="3234234";
$url1 = "$instance_url/services/data/v20.0/sobjects/Contact/$accID";
$curl1 = curl_init($url1);
curl_setopt($curl1, CURLOPT_HEADER, false);
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl1, CURLOPT_HTTPHEADER,
array("Authorization: OAuth $access_token"));
$json_response1 = curl_exec($curl1);
$status = curl_getinfo($curl1, CURLINFO_HTTP_CODE);
curl_close($curl1);
$objContact = json_decode($json_response1, TRUE);
//var_dump($objContact);
for($i=0; $i<count($objContact['attributes']); $i++) {
echo "Contact email is " . $objContact['Email'][$i] . "<BR>";
}
答案 0 :(得分:3)
你有一个数组数组,每个数组都有一个foreach($objContact as $data){
echo $data['Email'] . '<br>';
}
键,所以简单地说:
export class MyDtoDataSource extends DataSource<IMyDto> {
private _filterChange = new BehaviorSubject('');
public get filter(): string { return this._filterChange.value; }
public set filter(filter: string) { this._filterChange.next(filter); }
constructor(private _apiService: ApiService) {
super()
}
connect(): Observable<IMyDto[]> {
const displayDataChanges = [
this._apiService.getMyDtos(),
this._filterChange,
];
return Observable
.merge(...displayDataChanges)
.map((dtos: IMyDto[]) => dtos.filter(dto => dto.categories.map(i => i.name).includes(this.filter)));
}
disconnect() {
}
}
答案 1 :(得分:1)
请尝试foreach
循环:
foreach($objContact as $contact)
{
echo "Contact email is " . $contact['Email'] . "<br>";
}
或与for
循环类似:
for($i=0; $i<count($objContact); $i++)
{
echo "Contact email is " . $objContact[$i]['Email'] . "<BR>";
}