如何通過輸入關鍵字推送出相關文章呢?
我知道select是二維數組,跟
$arr?=?array( ????array( ????????'title'?=>?'測試', ????????'description'?=>?'測試內容', ????????'picUrl'?=>?'https://ssl.demenk.com/dyxcx/public/upload/default/20180822/3b15071c8e7f64d7edb1951acb692628.png', ????????'url'?=>?'http://www.baidu.com', ????), ????array( ????????'title'?=>?'測試111111111', ????????'description'?=>?'測試內容111111111', ????????'picUrl'?=>?'https://ssl.demenk.com/dyxcx/public/upload/default/20180822/a1e6d5575189994988a8c169eff67191.jpg', ????????'url'?=>?'http://www.taobao.com', ????), ????array( ????????'title'?=>?'測試22222222', ????????'description'?=>?'測試內容222222', ????????'picUrl'?=>?'https://ssl.demenk.com/dyxcx/public/upload/default/20180822/2ff3ce26c9233d179ff0184708f56137.jpg', ????????'url'?=>?'http://www.zhihu.com', ????), );
很像。
請問是把?
$postObj->Content
變成
$keywords?=?$postObj->Content;
這樣嗎?
我的邏輯是這樣寫的:
????????$keywords?=?$postObj->Content; ????????if(strtolower($postObj->MsgType)==?'text'?&&?trim($postObj->Content)?==?'tuwen1'){ ????????????$map['content']=['LIKE','%'.$keywords.'%']; ????????????$res?=?DB::name('article')->where($map)->select(); ?????? ????????????$toUser???=?$postObj->FromUserName; ????????????$fromUser?=?$postObj->ToUserName; ????????????$template?=?"<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <ArticleCount>".count(5)."</ArticleCount> <Articles>"; ????????????foreach($res?as?$k=>$v){ ????????????????$template?.=" <item> <Title><![CDATA[".$v['title']."]]></Title> <Description><![CDATA[".$v['description']."]]></Description> <PicUrl><![CDATA[".$v['picUrl']."]]></PicUrl> <Url><![CDATA[".$v['url']."]]></Url> </item>"; ????????????} ????????????$template?.="</Articles></xml>"; ????????????echo?sprintf($template,?$toUser,?$fromUser,?time(),??'news');
可是還是報錯,,,有大佬知道如何寫嗎?十分感謝。
2018-08-25
求助?。。?!