-
-
Save voxpelli/a4fbc66e9bc6dbfec8fa9b7654fdee59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"foo": "bar"} | |
<div>Hello world</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Parses JSON front matter into data and content | |
* | |
* Example: | |
* | |
* {"foo": "bar"} | |
* <div>Hello world</div> | |
*/ | |
function get_json_front_matter($data) { | |
$parts = explode("\n", $data, 2); | |
return [ | |
'data' => json_decode($parts[0]), | |
'content' => $parts[1] | |
]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment