May 4, 2011

PHP Explode after second comma | CyberSEO Pro | CyberSEO support forum

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

sp_TopicIcon
PHP Explode after second comma
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
October 3, 2025
11:19 am
Avatar
B8europe
Member
Members
Forum Posts: 49
Member Since:
February 16, 2016
sp_UserOfflineSmall Offline

I'm splitting a string with php explode after the first comma.

However, the string has changed and now has two commas, with one in the middle:

Login to see this link

$headshots = explode(',', $xml_tags['headshot']['val']);

How do I split a string after the second comma?

October 3, 2025
12:06 pm
Avatar
CyberSEO
Admin
Forum Posts: 4184
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

This question is not directly related to the CyberSEO Pro plugin. It concerns general PHP programming, specifically working with the explode() function to split strings. Writing or debugging custom PHP code that is not part of the plugin's internal logic is beyond the scope of plugin support.

However, to help users develop PHP snippets for CyberSEO Pro, we've created a free ChatGPT Support Assistant, which is a custom GPT available via this link: Login to see this link

This assistant is familiar with the architecture and API of CyberSEO Pro and can help you write PHP snippets that function properly within the plugin's environment.

Below is ChatGPT Support Assistant's response to your question:

If you need to split a string after the second comma (instead of splitting on every comma), you can use PHP's explode() function with a limit parameter.

Here's how it works:
By passing 3 as the third argument to explode(',', $string, 3), PHP will split the string into a maximum of three parts — meaning it will only split at the first two commas. The first element will be everything before the first comma, the second will be between the first and second commas, and the third will contain the rest of the string (including any additional commas).

For example:

Login to see the code

Then you can reconstruct the two sections like this:

Login to see the code

This way, $beforeSecondComma contains everything up to the second comma, and $afterSecondComma contains the rest. It's a clean solution when you're dealing with strings where only the first two commas matter and the rest should remain untouched.

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
24 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 87

harboot: 75

s.baryshev.aoasp: 68

Freedom: 61

Pandermos: 54

tormodg: 51

Member Stats:

Guest Posters: 337

Members: 3119

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1724

Posts: 8891

Newest Members:

hassanabr, xrprightnow, mouckoumbi, our728, km.chandrashekaran, bluest.recap.0x.icloud

Administrators: CyberSEO: 4184