Category: php functions
How to use substr_count()
int substr_count ( string $haystack , string $needle [, int $offset= 0 [, int $length ]] )
The substring count php function is very useful when you need to find out if there are instances of a certain string within a string. It counts how many instances are found. If all you need to know is whether or not a certain string is, use an if() statement to check for a number higher than 0.
<?php
if ($cnt = substr_count('onetwo- test 6 yhnos','test')> 0){
echo "yes test is in there $cnt times";
}
if ($cnt = substr_count('onetwo- test 6 yhnos','test')> 0){
echo "yes test is in there $cnt times";
}
rtrim See Also:
rtrim()
trim()
strip tags StripTags() php function
Striptags() is a php function that literally strips HTML tags out of files that are streamed in to php with a function like
stripslashes How to use stripslashes
<?php
$exampleString = 'My\ex\ampl\e';
$charlist = 'ea';
echo Echo is used in php scripts to output html characters to the screen. echo is one of the most used functions in the php language.
<?php

Leave a Comment
substr_count