psPrintIf() Print If
Description:
Prints a string if a var is not empty, also allows a place holder for said str if needed. Note: there is a trim() on the string
Usage:
psPrintIf($var, [$str]); if $str no provided, it will print the $var
Example:
$var = "Mike"; psPrintIf($var, "Hi __VAR__ "); // output: Hi Mike psPrintIf($var, "Hi Michael"); // output Hi Michael
$var = ""; psPrintIf($var, "Hello World"); // no output
Code:
function psPrintIf($var, $str="__VAR__") { $var = trim($var); if ($var != "") { $str = str_replace("__VAR__", $var, $str); print $str; } }
Changlelog:
|
|