Separating Arrays As Variables-PHP
How can I use the second array as a seperate variable? and print it as, for example, a link.
My current code is:
$result = $query->product('1149632')开发者_Go百科
->show(array('name','image','salePrice','url', 'sku'))->query();
print <<<THIS
<div>$result</div>
THIS;
Thanks
If that $query()
method call returns an array, then you can do something like this:
foreach ($result as $val) {
echo "<div>$val</div>\n";
}
echo"
<div><a href='{$result['url']}'>{$result['name']}</a> ${$result['salePrice']}</div>
";
精彩评论