다음은 내 get_first
방법 시도이지만 Fatal error: Uncaught Error: Cannot use object of type stdClass as array
오류가 발생합니다.
public function get_first($path, $args = [])
{
foreach ($data as $key => $single) {
if ($single[0]['email'] === $args['email_address']) {
$output = $single[0]['email'];
}
}
return $output;
}
다음과 같이 첫 번째 결과를 반환합니다.
object(stdClass)[407]
public 'id' => int 6
public 'email' => string '[email protected]' (length=25)
std 클래스 객체의 속성을 얻으려면 화살표를 사용해야하지만 여기서는 속성을 연관 배열로 가져 오려고했습니다.
foreach ($data as $key => $single) {
if ($single->email == $args['email_address']) {
$output = $single;
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다