You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
postfixadmin/smarty/libs/plugins/modifier.needle.php

56 lines
1.0 KiB
PHTML

<?php
/**
* Smarty shared plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Function: smarty_needle
* Purpose: Used to find a string in a string
* Options: enter "case" to make case senstative
* Example: needle( 'Gabe-was-here', 'here' ) returns true
* Example2: needle( 'Gabe was here', 'gabe' ) returns true
* Example: needle ('Gabe was there', 'sde') returns false
* Smarty Sample: {$haystack|needle:"string"}
* Smarty Sample: {$haystack|needle:"string":"case"}
* @author Gabe LeBlanc "raven"
* @param string
* @return boolean
*/
function smarty_modifier_needle($haystack, $needle, $cases = "nocase") {
if(!empty($haystack) ) {
if($cases == "nocase") {
if(stristr($haystack, $needle)) {
return true;
}else{
return false;
}
}elseif($cases == "case") {
if(strstr($haystack, $needle)) {
return true;
}else{
return false;
}
}
}else{
return false;
}
}
?>