webCOMAND

string_util::to_identifier()

Return a string as a valid identifier by:

  1. Removing all HTML entities and character values.
  2. Converting " & " to " and ".
  3. Normalizing accent characters.
  4. Removing any characters that are not upper- or lower-case letters or numbers.

Identifiers can be used as an cObject Key.

Prototype

string to_identifier(string $string)

Parameters

  • string - Text string that will be processed and turned into an identifier.

Return

A string containing only upper- and lower-case letters and numbers.

Example

// $identifier will be 'ThisisanExample'
$title = 'This is an Example';
$identifier = \io_comand_util\string_util::to_identifier($title);