嗨,我想知道,如果MySQL表中添加了一行,MySQL是否有办法自动发送电子邮件给自己?
我正在使用API并将JSON数组解码为PHP数组,但是当我使用foreach循环时它没有给我特定的值.这是原始JSON数组的片段:
"playerCredentials": {
"observerEncryptionKey": "blahblah",
"dataVersion": 0,
"playerId": 8675309,
"serverPort": 0,
"observer": true,
"summonerId": 0,
"championId": 0,
"observerServerIp": "111.111.111.111",
"gameId": 123456789,
"observerServerPort": 4388,
"lastSelectedSkinIndex": 0
},
Run Code Online (Sandbox Code Playgroud)
然后,我运行了这段代码:
$array = json_decode($json_array, true);
Run Code Online (Sandbox Code Playgroud)
然后将上述内容变为:
{ ["playerCredentials"]=> array(11)
{
["observerEncryptionKey"]=> string(32) "blahblah"
["dataVersion"]=> int(0)
["playerId"]=> int(8675309)
["serverPort"]=> int(0)
["observer"]=> bool(true)
["summonerId"]=> int(0)
["championId"]=> int(0)
["observerServerIp"]=> string(14) "111.111.111.111"
["gameId"]=> int(123456789)
["observerServerPort"]=> int(4338)
["lastSelectedSkinIndex"]=> int(0)
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行这个foreach循环时:
foreach($array['playerCredentials'] as $stats) {
echo $stats['playerId'];
}
Run Code Online (Sandbox Code Playgroud)
我得到的所有回报是82(我甚至不知道它来自哪里).但是,如果我运行这个:
foreach($array['playerCredentials'] as $stats) {
echo $stats."<br>";
}
Run Code Online (Sandbox Code Playgroud)
我得到了整个数组中的所有信息:
blahblah
0 …Run Code Online (Sandbox Code Playgroud)