Skip to content

Instantly share code, notes, and snippets.

@dmi3yy dmi3yy/ph.snippet.php
Last active Dec 17, 2015

Embed
What would you like to do?
ph snippet PHx alternative
<?php
/*
* Замена PHx для обработки плейсхолдеров
* Версия: 0.1
* Пример: [[ph? &fn=`mydate` &input=`[*pub_date*]` &options=`%d-%m-%Y %H:%M`]]
* Автор: Dmi3yy (dmi3yy@gmail.com)
*/
$output = isset($input)?$input:'';
$options = isset($options)?$options:'';
$fn = isset($fn)?$fn:'none';
switch($fn){
case 'upper':
case 'uppercase':
case 'strtoupper':
return mb_strtoupper( trim($output) );
break;
case 'lower':
case 'lowercase':
case 'strtolower':
return mb_strtolower( trim($output) );
break;
case 'date':
case 'mydate':
return strftime($options, strtotime($output));
break;
case "length":
case "len":
case "strlen":
return mb_strlen($output);
break;
default:
return trim($output);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.