Finding out number of URLs in a post

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
richey
Registered User
Posts: 636
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

Finding out number of URLs in a post

Post by richey »

Hello,

what's the recommended way to find out the # of URLs contained in a post now?

I found that many parsing functions have been transferred to s9e/text-formatter - as my own code doesn't work anymore, can I use one of these?

My dirty temporary 'hack' is

Code: Select all

substr_count(this->message,"://");
:oops:

Thanks,
r.
.
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Finding out number of URLs in a post

Post by warmweer »

richey wrote: Mon Aug 08, 2022 8:50 pm My dirty temporary 'hack' is

Code: Select all

substr_count(this->message,"://");
:oops:
What about urls such as www.phpbb.com which is a valid link www.phpbb.com ?
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
MarkDHamill
Registered User
Posts: 4885
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: Finding out number of URLs in a post

Post by MarkDHamill »

Use filter_var_array then count the number of items in the array.

https://www.php.net/manual/en/function. ... -array.php
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4885
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: Finding out number of URLs in a post

Post by MarkDHamill »

Actually, this is more elegant. See third response. Then count the number of elements in the array.

https://stackoverflow.com/questions/115 ... g-with-php
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.
Post Reply

Return to “[3.3.x] Support Forum”