Skip to content

Instantly share code, notes, and snippets.

@Dmi3yy
Last active December 17, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dmi3yy/5685795 to your computer and use it in GitHub Desktop.
Save Dmi3yy/5685795 to your computer and use it in GitHub Desktop.
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