如何通过索引访问RecursiveArrayIterator?

时间:2018-04-19 22:02:11

标签: php json

如何在没有循环的情况下通过索引访问mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { // Code to be executed when an ad finishes loading. } @Override public void onAdFailedToLoad(int errorCode) { // Code to be executed when an ad request fails. } @Override public void onAdOpened() { // Code to be executed when an ad opens an overlay that // covers the screen. } @Override public void onAdLeftApplication() { // Code to be executed when the user has left the app. } @Override public void onAdClosed() { // Code to be executed when when the user is about to return // to the app after tapping on an ad. } }); ?我有以下代码

RecursiveArrayIterator

我只想通过电子邮件发送密钥,如果我提供选项的密钥而不是值,则ChosenJS将无法正常工作

我可以执行另一个循环来发送密钥,这是我目前正在暂时执行的但是错误的,$json = file_get_contents("careers.json"); $jsonIterator = new RecursiveIteratorIterator( new RecursiveArrayIterator(json_decode($json, TRUE)), RecursiveIteratorIterator::SELF_FIRST); <select class="form-control position" name="position" required> <?php $option = 0; foreach($jsonIterator as $key => $val){ if(is_array($val)){ $option++; ?> <option value="<?= $option; ?>"><?= $key; ?></option> <?php }}?> </select> 建议在聊天存储Peehaa并访问它。

有许多可能的解决方案,但我有兴趣以这种方式访问​​它以用于教育目的

json_decode

Json示例,它是一个包含许多段落的文件,这是一个示例结构:

$index = $_POST['position'];
$key= $jsonIterator[$index];

0 个答案:

没有答案