andrewk
andrewk

Reputation: 3871

set a function equal to a variable so i can do this($var)

I have a function the_search() that just echoes what people searched for.

I want to put that in to another function, get_data($var) to get some data.

How can I set the_search(); equal to some $var so that I can do the following:

$thing = get_data('$var');

Upvotes: 2

Views: 1177

Answers (1)

NikiC
NikiC

Reputation: 101946

a) You could change the_search not to echo the data, but to return it.

b) You could use Output Buffering:

ob_start();
the_search();
$var = ob_get_clean();

Upvotes: 1

Related Questions