0

I am having difficulty iterating over an array of data. My Code is as follows:

$root = $_SERVER['DOCUMENT_ROOT'];
require $root.'/assets/js/mustache.php-2.13.0/src/Mustache/Autoloader.php';
include($root."/utilities.php");
Mustache_Autoloader::register();
$url = "http://development.somesite.com/pages/lookup/sql/getData.php?dir=A&process=20&d=O";
$r = json_decode(Insert($url));

$template = "{{{#r}}}<b>{{PropName}}</b></br>{{{/r}}}";

$m = new Mustache_Engine;
$html = $m->render($template, $r); 
echo "html: ".$html."</br>";
var_dump($r);

The result I get is:

html:

array(317) { [0]=> object(stdClass)#2 (2) { ["PropNo"]=> string(3) "409" ["PropName"]=> string(21) "WRD Avenue LLC" } [1]=> object(stdClass)#3 (2) { ["PropNo"]=> string(3) "410" ["PropName"]=> string(21) "1111 Avenue AB" }...}

The array was created using json_decode. I'm sure the answer is simple but I am clearly missing something here.

Thanks for your help.

Kunal Raut
  • 2,495
  • 2
  • 9
  • 25
M Becker
  • 73
  • 5

1 Answers1

0

I got it working as follows:

Changed $template to:

$template = "{{#r}}<b>{{PropName}}</b></br>{{/r}}";

And changed the render to:

$html = $m->render($template, array('r'=>$r)); 
M Becker
  • 73
  • 5