Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:05:46+00:00 2026-05-16T18:05:46+00:00

I have the following string in php: $string = ‘FEDCBA9876543210’; The string can be

  • 0

I have the following string in php:

$string = 'FEDCBA9876543210';

The string can be have 2 or more (I mean more) hexadecimal characters
I wanted to group string by 2 like :

$output_string = 'FE:DC:BA:98:76:54:32:10';

I wanted to use regex for that, I think I saw a way to do like “recursive regex” but I can’t remember it.

Any help appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:05:47+00:00Added an answer on May 16, 2026 at 6:05 pm

    If you don’t need to check the content, there is no use for regex.

    Try this

    $outputString = chunk_split($string, 2, ":");
    // generates: FE:DC:BA:98:76:54:32:10:
    

    You might need to remove the last “:”.

    Or this :

    $outputString = implode(":", str_split($string, 2));
    // generates: FE:DC:BA:98:76:54:32:10
    

    Resources :

    • http://www.w3schools.com – chunk_split()
    • http://www.w3schools.com – str_split()
    • http://www.w3schools.com – implode()

    On the same topic :

    • Split string into equal parts using PHP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following string in php: somedirectory/abc/morethings/[folder name] How can I parse
I have the following string: keyword|title|http://example.com/ I would like to use the PHP function
I have the following almost JSON string: <?php $string = '{0:{id:1,name:Antiek en Kunst,subs:[{id:2,name:Antiek |
I have the following string and would like to use str_replace or preg_replace to
I have the following string in PHP: <p> [#form id=1]</p> What is the pattern
So I have the following PHP string: $output = {playerId:1178,percentChange:0.1,averageDraftPosition:260,percentOwned:0.1,mostRecentNews:{news:Accardo was called up from
I have following Template string in mysql which i fetch through php. $msg =
I have the following string: $/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php I need to create regex pattern and take
I'm trying to convert a timestamp string to Date in PHP. I have following
(in PHP) I have the following string: $string = '<!--:fr--><p>Mamá lorem ipsum dolor sit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.