#!/usr/bin/env php in_array($word, exceptions) ? lcfirst($word) : ucfirst($word), $title_words ); $title_words[0] = ucfirst($title_words[0]); end($title_words); $key = key($title_words); $title_words[$key] = ucfirst($title_words[$key]); // Generate HTML title. $title = implode(' ', $title_words); $title = "

$title

\n\n"; // Generate post filename/URL. $filename = strtolower(implode('-', $title_words)); $date = date('Y-m-d'); $filename = "$date-$filename.md"; if (!$handle = fopen("./drafts/$filename", 'a')) { fwrite(STDERR, "Cannot append to file: $filename\n"); exit; } if (fwrite($handle, $title) === false) { fwrite(STDERR, "Cannot write contents to file: $filename\n"); exit; } printf("Created post %s\n", $filename);