0

If i have:

print_r($request->getRequestVars());

that prints out:

Array ( [n] => Coors [s] => 3 ) 

how would i print out coors?

echo $request->getRequestVars()->n;

is not working, and i've tried several other things. I know this is super basic but it's frustrating me

1
  • getRequestVars() returns an array, not an object. Commented Dec 18, 2012 at 19:09

3 Answers 3

2

Try:

<?php

$var = $request->getRequestVars();
echo $var['n'];

?>
Sign up to request clarification or add additional context in comments.

Comments

2

I assume that the method $request->getRequestVars(); acutally returns an array. So, you would have to do something along the lines of:

$foo = $request->getRequestVars();
echo $foo['n'];

Comments

2

Please note that $request->getRequestVars() returns array not object. PHP 5.4 has Function Array Dereferencing if that is what you are running then you can have:

echo $request->getRequestVars()['n'];

else

$v = $request->getRequestVars();
echo $v['n'];

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.