PHP Code 'Array' Loop Functions Create Alot of OverHead | CyberSEO Pro
May 4, 2011

PHP Code 'Array' Loop Functions Create Alot of OverHead | CyberSEO Pro | Support Forum


Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Related Related Topics sp_TopicIcon
PHP Code 'Array' Loop Functions Create Alot of OverHead
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
December 5, 2011
7:24 am

Hello Admin,

I’m finding that adding an “array check” function for bad words is creating alot of “overhead” and creating some error or causing PHP scripts to ‘time out’.

For instance the following script “times out” and never inserts a post (CyberSEO complains that there was an ‘error’ and not post was added, but I have no way of knowing what the error is):

Login to see the code

If I change the Array to just 3 words it does complete:

$arrayBadWords = array(‘copyright’,’bad1′,’bad2′,);

Any suggestion as to how this sort of functionality could be improved other than creating fa slow PHP ‘looping’ array?


December 5, 2011
1:28 pm
Forum Posts: 3461
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

First of all, your code is not well optimized because it continues to check for all “bad” keywords even if one of them was found (lines 4-8). This is just a wasting of your server resources which is the reason of those “overheads”.

The second thing is that this code runs for every post in the feed, including those that there syndicated already. You can skip these posts using special API function cseo_post_exists() which returns true if post already exists in the database (it uses the selected duplicated check method).

So here is a slightly optimized version of your code which also uses the cseo_post_exists() function to skip all the existing posts (note lines #1, #5 and #6):

Login to see the code

December 10, 2011
11:18 pm

Hi Admin,

Thank you, thank you thank you for your suggestions!!!

(will keep you posted)


Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 81

s.baryshev.aoasp: 63

Freedom: 61

MediFormatica: 49

B8europe: 47

saviulisse67: 45

Member Stats:

Guest Posters: 338

Members: 2465

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 4

Topics: 1459

Posts: 7293

Newest Members:

ernestorenovato, tamara.tlustenko, hasandogu, volkane169,, danielle.c.thompson

Administrators: CyberSEO: 3461