NameSilo

PHP/MySQL count script

Spaceship Spaceship
Watch

freeflow

Established Member
Impact
13
How can I count the number of times http appears in a table space entry?
I would like to use that number for an if statement to delete automated spam
entries from my forum when http appears more than 10 times.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
you could for example do :-

PHP:
<?php
$a = 'this is my http test which has a few http in it http';
$expression = '/http/';
preg_match_all($expression, $a, $matches);
$count = count($matches[0]);
echo $count;
?>
 
1
•••
Simpler way:

PHP:
<?php

$text = 'this is my http test which has a few http in it http';

echo substr_count($text, 'http'); // 3

?>
 
1
•••
What forum are you using? Also, are you wanting it to check retroactively (existing posts) or just have it check them from now on?
 
0
•••
Thanks everyone for your help! The spam filter works now. :D
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back