Integrated
  • Introduction
  • FTP伺服器架設
  • PHP-json格式的轉換
  • Google API
  • Meta Tag
  • 虛擬網址的設定
Powered by GitBook
On this page

Was this helpful?

PHP-json格式的轉換

在做一個專案下碰到兩個json格式,

  1. 一個是物件:呼叫的方式是$data->key

  2. 另一個是陣列:呼叫的方式是$data['key']

一個專案最好只要有一種格式就好,如果出現兩種,就必須把一個轉成另一個,我是習慣轉成陣列格式。

$data = (array)$data; //這樣就可以強制轉成陣列



// convert json to array
$array = json_decode($json, true);
//  create a new collection instance from the array
collect($array);
PreviousFTP伺服器架設NextGoogle API

Last updated 5 years ago

Was this helpful?