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 9239509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:00:15+00:00 2026-06-18T08:00:15+00:00

I want to replace all emails in a string with an image of the

  • 0

I want to replace all emails in a string with an image of the email.

I already have a PHP function to create an image of the text supplied to it. So I am just looking for how to replace the emails with the corresponding basse64engoded string.

Here is what I want exactly:

"my email is example@example.com and my phone no is 349080353"

I want a function to convert the above string into following:

my email is <img src="image.php?id=ZG5zLWFkbWluQ437yifhb2dsZS5jb20="> and my phone no is 349080353

The id of the email is encoded with base64_encode. So, I want a function to search and replace email with the following img tag and encode each email with base64_encode and supply it to ‘id’.

  • 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-06-18T08:00:17+00:00Added an answer on June 18, 2026 at 8:00 am

    Try this code

    $email_pattern = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/';
    
    $html = preg_replace_callback($email_pattern, "encode_email", "my email is example@example.com and my phone no is 349080353");
    
    echo $html;
    
    function encode_email($matches){
        return '<img src="image.php?id='. base64_encode($matches[0]) .'">';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to replace all mailto: links in html with plain emails. In: text
I want to replace all unnecessary breaks in a string. I have written a
I want to replace all "%" with "%%" in my string. However, my string
I want to replace all displaying text with something like @@@@. It mean user
I have alot of text inputs in my application, and I want to create
I want to replace all & characters into \& with String.gsub (or a other
I don't want to create templates for all transactional emails but I would like
I have a function that sends out site emails (using phpmailer), what I want
I want to replace all html codes to empty space. I think I should
I want to replace all occurrences of a comma in a few lines of

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.