Last active
December 17, 2015 22:59
-
-
Save Dmi3yy/5685795 to your computer and use it in GitHub Desktop.
ph snippet PHx alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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