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

  • SEARCH
  • Home
  • 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 7073137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:53:36+00:00 2026-05-28T05:53:36+00:00

I am using str_replace to replace anything inside a link text (anchor text). I

  • 0

I am using str_replace to replace anything inside a link text (anchor text).

I want to replace the word ‘SMS’ from the anchor text inside a wordpress category name,

<?php echo str_replace("SMS","",(the_category(', '))) ; ?>

but it doesn’t work. It does work for a replacement of normal string,

$txt = "Sufyan"
    <?php echo str_replace("S","a",$txt) ; ?> 

The above code works but it doesn’t work when I want to replace something from anchor text.

  • 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-28T05:53:37+00:00Added an answer on May 28, 2026 at 5:53 am

    the_category() is a template tag with echos its results without returning them. Basic rule of thumb: if it starts with ‘the_‘ it echos without returning.

    Change that line to

    <?php echo str_replace("SMS","",(get_the_category_list(', '))) ; ?>
    

    and str_replace() should work as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using str_replace I want to change $url from this: $url = http://example.com/images/lala1.jpg to this
Hi I want to do a simple replace using str_replace, like Classic ASP. $strName=Blush
I need to convert lib_someString to <a href=someString>someString</a> inside a block of text using
I want to insert | in place of space using str_replace , but when
Here I have 2 methods using str_replace to replace strings in a given phrase.
I'm currently using PHP's str_replace to replace a particular value with another, in a
I have a strange problem. I read text from a text file replace all
i have a lil problem here..i'm using str_replace to replace the most common words..and
I'm using str_replace and it's not working correctly. I have a text area, which
I need to extract the name of the direct sub directory from a full

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.