0

I'm kinda confused in my case,

$counts="$s{$process[$count]}";

if i echo $counts with

echo "$counts";

it still showing the value, how can i echo $counts to show the variable name

$steamroller

(in this case the process is 'team', and count is 'roller')) instead of the value of the variable $system?

EDIT okay i found it by myself it should be

$counts='$s'.$process."[".$count."]";

thank you..

unknown.person
  • 135
  • 2
  • 11
  • Just use `single quotes` instead of `double quotes` in echo `statement` plz check here: https://3v4l.org/VZHG8 – Ali May 17 '16 at 04:53
  • `$counts` or `$count`? – Thamilhan May 17 '16 at 04:53
  • Possible duplicate of http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php – Noman Ghani May 17 '16 at 04:56
  • @Ali that's not what i mean, the $steamroller itself is a variable that has a value, so every time i echo $count it always showing the value of $steamroller instead of "$steamroller", the wrong thing i think is how i save the variable in $counts – unknown.person May 17 '16 at 04:59
  • @FrayneKonok im sorry sir, i rate up your answer yesterday, maybe my internet connection is down, after i check again this time, my rate up and green check is missing, looks like it wasnt make it, sorry :) – unknown.person May 18 '16 at 04:10
  • its okey, just remove the last comment – Murad Hasan May 18 '16 at 04:13

2 Answers2

2

Just make this:

$s = 's';
$count = 1;
$process[$count] = 'teamroller';

echo $counts = "$$s{$process[$count]}"; // $steamroller
Murad Hasan
  • 9,565
  • 2
  • 21
  • 42
2

if you echo variable name in "" , php parse that variable an echo its value, if you want echo variable name with '' like this:

echo '$counts';  
Hossein
  • 1,301
  • 1
  • 12
  • 23