본문으로 바로가기

php json 처리

category Coding/PHP MySQL 2016. 2. 27. 12:01
반응형
$result = '{"Cancelled":false,"MessageID":"402f481b-c420-481f-b129-7b2d8ce7cf0a","Queued":false,"SMSError":2,"SMSIncomingMessages":null,"Sent":false,"SentDateTime":"\/Date(-62135578800000-0500)\/"}';
$json = json_decode($result, true);
print_r($json);

OUTPUT

Array
(
    [Cancelled] => 
    [MessageID] => 402f481b-c420-481f-b129-7b2d8ce7cf0a
    [Queued] => 
    [SMSError] => 2
    [SMSIncomingMessages] => 
    [Sent] => 
    [SentDateTime] => /Date(-62135578800000-0500)/
)

Now you can work with $json variable as an array:

echo $json['MessageID'];
echo $json['SMSError'];
// other stuff


한마디로 decode 시 true 인자를 주면 return값이 배열형태로 온다.

반응형

'Coding > PHP MySQL' 카테고리의 다른 글

PHP 파싱  (1) 2016.06.01
API를 이용한 롤 전적검색 사이트 만들기  (15) 2016.02.27
PHP curl  (0) 2016.02.26
PHP 소켓  (0) 2016.02.26
롤 API Key 발급받기  (0) 2016.02.26