private function news($news)
{
$articles = array();
foreach ($news as $key => $value) {
list($articles[$key]['Title'], $articles[$key]['Description'], $articles[$key]['PicUrl'], $articles[$key]['Url']) = $value;
if ($key >= 5) {
break;
}
}
$this->data['ArticleCount'] = count($articles);
$this->data['Articles'] = $articles;
}
以上这段可以实现在微信公众平台自动回复图文信息5条,该如何把下面的这段也加上可以设置回复数量的代码?下面这段代码仅显示一条。
private function data2xml($xml, $data, $item = 'item')
{
foreach ($data as $key => $value) {
is_numeric($key) && ($key = $item);
if (is_array($value) || is_object($value)) {
$child = $xml->addChild($key);
$this->data2xml($child, $value, $item);
} else {
if (is_numeric($value)) {
$child = $xml->addChild($key, $value);
} else {
$child = $xml->addChild($key);
$node = dom_import_simplexml($child);
$node->appendChild($node->ownerDocument->createCDATASection($value));
}
}
}
}
{
$articles = array();
foreach ($news as $key => $value) {
list($articles[$key]['Title'], $articles[$key]['Description'], $articles[$key]['PicUrl'], $articles[$key]['Url']) = $value;
if ($key >= 5) {
break;
}
}
$this->data['ArticleCount'] = count($articles);
$this->data['Articles'] = $articles;
}
以上这段可以实现在微信公众平台自动回复图文信息5条,该如何把下面的这段也加上可以设置回复数量的代码?下面这段代码仅显示一条。
private function data2xml($xml, $data, $item = 'item')
{
foreach ($data as $key => $value) {
is_numeric($key) && ($key = $item);
if (is_array($value) || is_object($value)) {
$child = $xml->addChild($key);
$this->data2xml($child, $value, $item);
} else {
if (is_numeric($value)) {
$child = $xml->addChild($key, $value);
} else {
$child = $xml->addChild($key);
$node = dom_import_simplexml($child);
$node->appendChild($node->ownerDocument->createCDATASection($value));
}
}
}
}