AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

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:
<?php
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:
<?php
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":
<?php
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

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home
PHP Introduction
PHP Install
PHP Syntax
PHP Variables
PHP Echo and Print
PHP Data Types
PHP String Function
PHP Constants
PHP Operator Types
PHP If Else and Elseif
PHP Switch
PHP While Loops
PHP Loop For Do Foreach
PHP Array
Convert Array to String
PHP Function
PHP GET and POST
PHP Date/Time Functions
PHP Login
PHP Delete Element
PHP eregi_replace()
PHP mysql_query()
PHP Errors to Display
PHP Loop For Do Foreach

PHP forms
PHP Form Example
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Upload Image, display, edit and delete i...
Login Form with Image background...
How to Create an Image with Transparent ...
Portfolio Gallery Website with filtering...
Simple pagination script PHP MySQLi...
Center Image in div...
Image Hover Overlay Fade...
Sticky image / element / div on scroll...
Responsive images...
Create rounded image in HTML CSS...
Add border around image...
Position Text Over an Image HTML CSS res...
Create a Slideshow Images Gallery...
Create a Sticky Sidebar...
Search bar using CSS HTML...
Shrink Navigation Menu on Scroll...
How to Create Accordion HTML Templates...
Dropdown menu in the navigation bar...
Responsive Top Navigation Bar with mobil...
Split horizontal navigation bar...