I have the following function.
printArray($_POST);
function printArray($array){
foreach ($array as $key => $value){
echo "$key: $value <br>";
}
}
I modified it from here... Print $_POST variable name along with value
It gets all my html values along with there variable names and echos them. I need to save the output to variable. I've tried using ob..
printArray($_POST);
ob_start();
function printArray($array){
foreach ($array as $key => $value){
echo "$key: $value <br>";
}
}
$out = ob_get_contents();
ob_end_clean();
print $out;
and that just gives me nothing. Ive tried just saving my echo to a variable and that gets me closer...
&out = “”
function printArray($array){
foreach ($array as $key => $value){
$out = "$key: $value <br>";
}
}
but it only gives me the last value in my output. Help me out here what am i doing wrong.
NOTE: I screwed up and forgot to modify one of my functions to show what I was doing, whoops..
";` inside ... then $output should contain what you want(?) after the loop, no? – CBroe Nov 29 '21 at 08:56