PHP : metaphone() function
The metaphone() function is used to calculate the metaphone key of a string.
Metaphone is a phonetic algorithm developed by Lawrence Philips. The algorithm produces variable length keys as its output, as opposed to Soundex's fixed-length keys. Similar sounding words share the same keys. It uses a larger set of rules for English pronunciation. Metaphone keys are very useful for text search and text matching applications.
(PHP 4 and above)
|input_string||The input string.||Required||String|
|key_length||Maximum length of the metaphone key.||Optional||Integer|
Returns the metaphone key as a string, FALSE in failure.
Value Type: String.
<?php $str = "w3resource"; echo $str; echo "<br />"; $str1 = "dual"; $str2 = "dwell"; echo metaphone($str1); echo "<br />"; echo metaphone($str2); ?>
w3resource TL TWL
PHP: Tips of the Day
$_GET: An associative array of variables passed to the current script via the URL parameters
$_GET is an array that contains all the URL parameters; these are the whatever is after the ? in the URL.
Using http://www.example.com/index.php?myVar=myVal as an example. This information from this URL can be obtained by accessing in this format $_GET["myVar"] and the result of this will be myVal.
Using some code for those that don't like reading.
<?php // URL = http://www.example.com/index.php?myVar=myVal echo $_GET["myVar"] == "myVal" ? "true" : "false"; // returns "true" ?>
The above example makes use of the ternary operator.
This shows how you can access the value from the URL using the $_GET superglobal.
Now another example! gasp
// URL = http://www.example.com/index.php?myVar=myVal&myVar2=myVal2 echo $_GET["myVar"]; // returns "myVal" echo $_GET["myVar2"]; // returns "myVal2"
It is possible to send multiple variables through the URL by separating them with an ampersand (&) character.
It is very important not to send any sensitive information via the URL as it will stay in history of the computer and will be visible to anyone that can access that browser.
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework