first

Description

Returns the first element or word of a list or string.

mixed first( mixed input [, string prior])

If passed a list, returns the first element of that list. If passed a string, returns the first word in that string (using spaces as the separator). This can be useful for extracting a user’s first name from theĀ name property. Optionally, you can pass a second string parameter to return the string value before the first instance of prior.

Examples

{first([1, 2, 3])}    ---> 1
{first('Joe Smith')} ---> Joe
{first('Mrs. Meyer','.')} ---> Mrs
{first('Mrs. Meyer','eyer')} ---> Mrs. M

If the variableĀ name is set on your subscribers and it includes both their first and last names, you could use this in a template to call just the user’s first name:

Dear {first(name)},
Top