开发者

Separating Arrays As Variables-PHP

开发者 https://www.devze.com 2023-02-18 10:07 出处:网络
How can I use the second array as a seperate variable? and print it as, for example, a link. My current code is:

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>  

"; 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号