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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:46:40+00:00 2026-06-01T14:46:40+00:00

$fr = hammad; $frhammad = nuthing; echo $fr{$fr}; Output: h Whereas the expected output

  • 0
$fr = "hammad";
$frhammad = "nuthing";
echo $fr{$fr};

Output:
h

Whereas the expected output was

"Nuthing"

What Should be the format to echo “Nuthing”?

  • 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-01T14:46:42+00:00Added an answer on June 1, 2026 at 2:46 pm

    Because $x{$n} is standard syntax that treats the string $x as an array of characters, where $n is the numeric index position of a character in that aray. In your case the index position is identified by $fr, which is a non-numeric string, so PHP’s loose typing is converting it to an integer 0, and so echoing the character at position 0… the first character of the string

    EDIT

    obligatory quote from the manual:

    String access and modification by character

    Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. Think of a string as an array of characters for this purpose. The functions substr() and substr_replace() can be used when you want to extract or replace more than 1 character.

    Note: Strings may also be accessed using braces, as in $str{42}, for the same purpose.

    EDIT #2

    To answer your latest question from the comments:

    how would I concatenate the name of variables as I have given in it
    question?

    $fr = "hammad"; 
    $frhammad = "nuthing"; 
    $varName = 'fr'.$fr;
    echo $$varName; 
    

    or

    $fr = "hammad";
    $frhammad = "nuthing";
    echo ${'fr'.$fr};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to create html list from this code - ali - hammad -
Text.Blaze has an operator ! to add attributes to html: option ! id bla
This package has some functions to turn recursive functions into dynamic programming recursive functions,
Is there an efficient algorithm to compute the smallest integer N such that N!
I have 100 daughter files with the same extension like thin1.txt thin2.txt thin3.txt .
I have a nested, mutual recursive data structure , and want to associate computational
I am making a website and I have made a form fields like email
I'm trying to filter a list that contains the Fibonacci numbers. What I need
I find myself doing more and more scripting in haskell. But there are some
I want to connect mysql database locally with android emulator. I used http GET

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.