PHP/MySQL count script

SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
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
Close
Thanks everyone for your help! The spam filter works now. :D
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back