<?php
# String Functions
// Function strlen() returns the length of the string, example:
echo strlen ("Nice to meet you!") . "\n"; /* output - 17 */
// Function strrev() returns the Reverse of the string, example:
echo strrev ("Nice to meet you!") . "\n"; /* output - !uoy teem ot eciN */
// Function strpos() tries to find the second parameter and returns its index. example:
echo strpos ("Nice to meet you", "you") . "\n"; /* output - 13 */;
// Function str_replace() replaces the word "Hello" with "Hi" , example:
echo ("Hello", "Hi", "Hello there") . "\n"; // outputs - Hi there;
// Function substr() returns the substring between given indexes, example:
echo substr("Nice to meet you", "5") . "\n"; // outputs - to meet you;
echo substr("Nice to meet you", 5, 3) . "\n"; // outputs - to meet you;
// Function trim() removes whitespaces from sides of the string, example:
echo trim(" Nice to meet you ") . "\n"; // outputs - Nice to meet you;
// Function strtoupper() converts the string to upper case, example:
echo strtoupper("Nice to meet you") . "\n"; //outputs - NICE TO MEET YOU;
// Function strtolower() converts the string to lower case, example:
echo strtolower("NICE To Meet You") ; //outputs - nice to meet you;
// Function explode() breaks the string by its delimiter, example:
print_r (explode(" ", "It's the first day of the course!"));
// Function implode() joins the array element based on the delimiter and returns the string, example:
echo implode(" ", ['Nice', 'to', 'meet', 'you']); //outputs - Nice to meet you;
// The PHP str_word_count() function counts the number of words in a string, example:
echo str_word_count("Nice to meet you!"); // outputs - 4
?>