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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:33:38+00:00 2026-05-16T05:33:38+00:00

I haven’t found anytihng in Google or the PHP manual, believe it or not.

  • 0

I haven’t found anytihng in Google or the PHP manual, believe it or not. I would’ve thought there would be a string operation for something like this, maybe there is and I’m just uber blind today…

I have a php page, and when the button gets clicked, I would like to change a string of text on that page with something else.

So I was wondering if I could set the id="" attrib of the <p> to id=”something” and then in my php code do something like this:

<?php
    $something = "this will replace existing text in the something paragraph...";
?>

Can somebody please point me in the right direction? As the above did not work.

Thank you 🙂

UPDATE


I was able to get it working using the following sample:

Place this code above the <html> tag:

<?php
$existing  = "default message here";
    $something = "message displayed if form filled out.";
    $ne = $_REQUEST["name"];

    if ($ne == null) {
      $output = $existing;
    } else {
      $output = $something;
    }
?>

And place the following where ever your message is to be displayed:

<?php echo $output ?>
  • 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-16T05:33:39+00:00Added an answer on May 16, 2026 at 5:33 am

    As far as I can get from your very fuzzy question, usually you don’t need string manipulation if you have source data – you just substitute one data with another, this way:

    <?php
        $existing  = "existing text";
        $something = "this will replace existing text in the something paragraph...";
        if (empty($_GET['button'])) {
          $output = $existing;
        } else {
          $output = $something;
        }
    ?>
    <html>
    <and stuff>
    <p><?php echo $output ?></p>
    </html>
    

    but why not to ask a question bringing a real example of what you need? instead of foggy explanations in terms you aren’t good with?

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

Sidebar

Related Questions

I haven't so far found how I can most easily check if a string
Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I haven't found a straight answer to how to make an animation in a
I haven't found a coherent answer to my quesion here :( My server's ISP
Haven't found what i'm looking for so far. I want to redirect all my
Haven't found this in my search on Stackoverflow - I know I've seen a
haven't used regex replaces much and am not sure if how I have done
Haven't found anything useful about this on the internet. I'm using my Windows 7
I haven't found any get equivalent to appendBytes. If I've understood getBytes correctly, that

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.