← CodePrimer
PHP Beginner Basics

Common PHP string functions

How do I count, reverse, or replace text?

strlen, strpos, str_replace…

Sample
<?php
$text = 'Web Development';
echo strlen($text);
echo str_word_count($text);
echo strrev($text);
echo strpos($text, 'Dev');
echo str_replace('Web', 'App', $text);

Notes

strpos returns false when not found — check with ===.

Keywords: strlen · strpos · str_replace · strrev · string

Related

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share