{assign var=firstletter value=$entry->company_name|substr:0:1}
Looking to have code for first char for any words:
company_name : Smarty Php
The output is SP
company_name : Words
The output is W
{assign var=firstletter value=$entry->company_name|substr:0:1}
Looking to have code for first char for any words:
company_name : Smarty Php
The output is SP
company_name : Words
The output is W
Hi alouty,
Something like this should work:
function getAcronym($string)
{
$words = explode(" ", $string);
$acronym = "";
foreach ($words as $w) {
$acronym .= $w[0];
}
return $acronym;
}
// Register function with Smarty
$smarty->register_modifier('get_acronym', 'getAcronym');
then in your template, do:
{assign var=firstletter value=$entry->company_name|get_acronym}
Thank you.