我有一個腳本從外部API中提取數據。輸出示例如下。從JSON數組獲取特定數據。 [PHP]
[{"id": "579144bbfbd8f54f53f5394b", "username": "test1", "type": "1", "email": "[email protected]", "status": on},{"id": "afadfatqwertqr", "username": "test2", "type": "1", "email": "[email protected]", "status": on}]
我想單獨從字符串中將id設置爲一個變量。它也必須是用戶名特定的,但任何支持將不勝感激。一直在絞盡腦汁,先謝謝了!
不使用正則表達式,如果它的json字符串,使用'json_decode'。使用適當的工具,而不是正則表達式 – Ghost
建議使用'json_decode' –