Я делаю символьную веб-страницу для проекта, и я новичок в изучении PHP, и, по сути, я пытаюсь передать ключ и извлечь указанный c объект из массива json. Это начало моего php файла:
<?
$character = $_GET['character'];
$json = file_get_contents("abilities.json");
....json parsing here halp....
?>
$ символа, переданного jquery в моем html файле:
function getAbilities(){
$.getJSON("read_stats.php", {"character": "Commando"}, function(data){
//jquery loop here
});
}
Мой JSON файл I Созданный выглядит следующим образом:
[
{"Commando":[
{"double_tap": "Shoot twice for 2x90% damage."},
{"phase_round": "Fire a piercing bullet for 230% damage."},
{"tactical_dive": "Roll a short distance."},
{"suppressive_fire": "Fire rapidly, stunning enimes for 6x100% damage."}
]},
{"Huntress":[
{"strafe": "Fire a seeking arrow for 150% damage. Can be used while sprinting."},
{"laser_glaive": "Throw a seeking glaive that bounces up to 6 times for 250% damage. Damage increases by 10% per bounce"},
{"blink": "Disappear and teleport forward."},
{"phase_blink": "Replaces Blink. Disappear and teleport a short distance. Can store up to 3 charges."},
{"arrow_rain": "Teleport into the sky. Target an area to rain arrows, slowing all enemies and dealing 225% damage per second."},
{"ballista": "Replaces Arrow Rain. Teleport backwards into the sky. Fire up to 3 energy bolts, dealing 3x900% damage."}
]} ......etc. ]
Итак, у меня есть массив JSON объектов, ключом является имя персонажа, а значением является еще один массив аблиций, моя конечная цель - иметь возможность печатать каждой способности, но это можно было бы обработать с помощью jquery, если бы мне удалось просто извлечь правильный JSON объект из массива. Любая помощь или указатели будут очень благодарны !!!!