Page · Mecha CMS

Working with pages.

$page::apart()

Author: Taufik Nurrohman · 229 Views

Tweet

Convert page file content into array of page data.

Page::apart($input, $key = null, $fail = null, $eval = false);

Example:

Convert page file content into array:

$input = '---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: HTML
status: 1
...

<p>Page content.</p>';

$test_1 = Page::apart($input);
$test_2 = Page::apart($input, 'type');

Result:

$test_1 = [
    'title' => 'Page Title',
    'description' => 'Page description.',
    'author' => 'Taufik Nurrohman',
    'type' => 'HTML',
    'status' => '1', // a string
    'content' => '<p>Page content.</p>'
];
$test_2 = 'HTML';