Skip to content

Instantly share code, notes, and snippets.

@lsolesen
Created May 4, 2011 14:27
Show Gist options
  • Save lsolesen/955307 to your computer and use it in GitHub Desktop.
Save lsolesen/955307 to your computer and use it in GitHub Desktop.
How do you get the YAML frontmatter of a file?
<?php
$string = '---
layout: default
title: Some title - yeah, right
---
<h1>Tester</h1>
<p>Some content</p>';
preg_match("'/---.*?---/s'", $content, $yaml_frontmatter);
print_r($yaml_frontmatter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment