第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

一個函數(shù)的用戶變量,在另一個函數(shù)中

一個函數(shù)的用戶變量,在另一個函數(shù)中

PHP
HUWWW 2022-07-02 15:22:10
我有一個 Laravel 應(yīng)用程序,其 PHP 代碼如下:   public function handle()    {                            $post_item->category_id = $source->category_id;                            $post_item->featured = 0;                            $post_item->type = Posts::TYPE_SOURCE;                            $post_item->render_type = $item['render_type'];                            $post_item->source_id = $source->id;                            $post_item->description = is_array($item['description'])?'':$item['description'];                            $post_item->featured_image = $item['featured_image'];                            $post_item->video_embed_code = $item['video_embed_code'];                            $post_item->dont_show_author_publisher = $source->dont_show_author_publisher;                            $post_item->show_post_source = $source->show_post_source;                            $post_item->show_author_box = $source->dont_show_author_publisher == 1 ? 0 : 1;                            $post_item->show_author_socials = $source->dont_show_author_publisher == 1 ? 0 : 1;                            $post_item->rating_box = 0;                            $post_item->created_at = $item['pubDate'];                            $post_item->views = 1;                            $post_item->save();                            $this->createTags($item['categories'], $post_item->id);                           // This is where I want to add my echo   }   }我試圖在評論的地方之后回顯標題和標簽,但它無法提供正確的輸出。我想知道我是否使用了正確的方法或者我的解決方法是完全錯誤的。我在注釋部分使用此代碼:$tweet = $post_item->title . ' tags: ' . $post_item->tags;做了一些測試后,我意識到如果我使用var_dump($tag);緊接著foreach ($tags as $tag)在我的createTags 函數(shù)中,似乎所有標簽都正確輸出。我想知道我是否可以將所有 $tags 存儲在 createTag 函數(shù)的 foreach 中,在一個全局訪問的變量下,該變量將在回顯的初始句柄函數(shù)中使用。
查看完整描述

2 回答

?
侃侃無極

TA貢獻2051條經(jīng)驗 獲得超10個贊

猜測 post item 模型有一個關(guān)系“標簽”,你可以試試這個:

$tweet = $post_item->title . ' tags: ' . implode(', ', $post_item->tags->toArray());

此外,如果您只想在注釋位置回顯標簽,請嘗試以下操作:

echo implode(',', $item['categories']);


查看完整回答
反對 回復 2022-07-02
?
尚方寶劍之說

TA貢獻1788條經(jīng)驗 獲得超4個贊

嘗試如果 $post_item->tags - 是數(shù)組然后

$tweet = $post_item->title . ' tags: ' . implode(', ', $post_item->tags);

如果 - 收集然后

$tweet = $post_item->title . ' tags: ' . $post_item->tags->join(', ');


查看完整回答
反對 回復 2022-07-02
  • 2 回答
  • 0 關(guān)注
  • 128 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號