I have a list of arrays and need them to output with a printf statement
<?php $example = array("first" => "Bob", "last" => "Smith", "address" => "123 Spruce st" ); $example = array("first" => "Sara", "last" => "Blask", "address" => "5678 Maple ct" ); foreach ($example as $key => $val) { printf("<p>hello my name is %s %s and i live at %s</p>",$example['first'],$example['last'], $example['address']); } ?> The above just outputs the last array, i need it to loop through all of the arrays and produce a <p> with the supplied key => value combinations. this is only a simplified example as the real world code will be more complex in the outputted html
I tried
foreach ($example as $arr){ printf("<p>hello my name is %s %s and i live at %s</p>",$arr['first'],$arr['last'], $arr['address']); } but it only outputs a single character for each key => value
$exampletwice - the second one will over-write the first one. That definitely won't help.