Tag Archives: String

sscanf()

It parses input from a string according to a format

Example

<?php
$string = “first:php second:code”;
sscanf($string,”%s%s”,$first,$second);
echo $first.$second;
?>

Output

first:phpsecond:code

soundex()

It calculates the  soundex key of a string

  • A soundex key is a four character long alphanumeric string that represent English pronunciation of a word.
  • The soundex() function can be used for spelling applications.
  • The soundex() function creates the same key for similar sounding words.

Example

<?php
 echo soundex("phpcode");
 ?>

Output

P123

quotemeta()

The quotemeta() function adds backslashes in front of some predefined characters in a string.

This function can be used to escape characters with special meanings, such as ( ), [ ], and * in SQL.

This function is binary-safe.

The predefined characters are:

  • period (.)
  • backslash (\)
  • plus sign (+)
  • asterisk (*)
  • question mark (?)
  • brackets ([])
  • caret (^)
  • dollar sign ($)
  • parenthesis (())

Example

<?php
 echo quotemeta("php(code)'");
 ?>

Output

php(code)’