HOME | PHP Tutorial | CSS
facebook icon
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

PHP Strings Function

<< Previous Page
PHP Data Types
Next Page >>
PHP Constants

Here are some of the most used PHP functions to manipulate strings.

strlen() - This function return the Length of a String

Example 1:
echo strlen("Hello there, how are you!"); // outputs 25

explode (delimiter, string)

Explode function is used to break a string into multiple strings, very useful when working with files in the form of a database. Example using explode function:

Example 2:
<? Php
$string = 'I want to learn PHP';
$array = explode(' ', $string);
echo '<pre>' .print_r ($array, true). '</pre>'; // we use pre for a better display of the array
Output: Array
[0}=> I
[1}=> want
[2}=> to
[3}=> learn
[4}=> PHP

str_word_count() This function count words in a string

The PHP str_word_count() function counts the number of all words in a string.

Example 3:
echo str_word_count("Hello world! I want to learn PHP"); // outputs 7

str_replace() - Replace Text in a String

The PHP str_replace() function is one of the most used and replaces some characters with other characters in a string.

Example 4: Replace in text "world" with "Any":
echo str_replace("world", "Any", "Hello world! I want to learn PHP");
// outputs: Hello Any! I want to learn PHP

<< Previous Page
PHP Data Types
Next Page >>
PHP Constants

PHP String Functions - php tutorial

3360. PHP Introduction
PHP tutorial - Introduction.

3223. PHP 5 switch Statement , php tutorial
PHP 5 switch Statement php tutorial

2243. PHP Tutorial - Data types
PHP like most other programming languages supports various data types. It is very important to understand that variable cand act in a distinct way depending on the type of data they contain.

3354. PHP For Loops
Learn about PHP for loops with this PHP tutorial.

3277. Mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in, php tutorial
Mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in php tutorial

php tutorials and introduction. What is php and how to write php

Your add here
PHP strstr() function

PHP print() function

PHP html_entity_decode() function

PHP ucfirst() function

PHP strtolower() function

PHP strcmp() function

PHP printf() function

PHP str_repeat() function

PHP ltrim() function

PHP htmlspecialchars_decode() function

PHP strip_tags() function

PHP htmlentities() function

PHP define() function

PHP ucwords() function

PHP str_replace() function

PHP substr() function

PHP Array - What is an Array?
PHP GET and POST to store data on server
HTML Text Color
HTML button link - How to create a button style in HTML
PHP Tutorial - Learn PHP in simple and easy steps starting from basic