PLEASE NOTE BEFORE READING:
- Im making use of wordpress, divi and sportspress
- Im trying to loop through these JSON strings and output them on my profile page (wordpress post)
- Php code are added to posts with this plugin: Plugin Page
- Im pulling JSON strings via an API(no problems encountered - only mentioning this here)
- Im aware that there are similar questions, however, this is wordpress related and the answer could be either a solution for a WORDPRESS post OR a different implementation suggestion that might be more fitting for this CMS. This means im willing to change the methods used to output these strings :)
The JSON string:
{"name":"MaartenPAC","level":30}
Im trying to output the JSON string inside a wordpress post with the following code:
// Loop through Array
$profile1Array = {"name":"MaartenPAC","level":30}; // This is the PHP Array
foreach ($profile1Array as $key => $value) {
echo $value["name"] . ", " . $value["level"] . "<br>";
}
The Problem:
Im getting no output at all.I'm not sure if this is a syntax error perhaps? The plugin takes the php code above and generates a shortcode that can be pasted inside a post (one can think of it as a "php include" I guess?). Im still looking into this myself and will keep this question updated.