通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
# collection格式化markdown数据列表 有如下数据: ``` $messages = [ 'Should be working now for all Providers.', 'If you see one where spaces are in the title let me know.', 'But there should not have blank in the key of config or .env file.' ]; ``` 格式化成Markdown的li格式数据,如下: ``` - Should be working now for all Providers. \n - If you see one where spaces are in the title let me know. \n - But there should not have blank in the key of config or .env file. ``` ## 使用foreach循环解决 ``` $messages = [ 'Should be working now for all Providers.', 'If you see one where spaces are in the title let me know.', 'But there should not have blank in the key of config or .env file.' ]; $comment = '- ' . array_shift($messages); foreach ($messages as $message) { $comment .= "\n - ${message}"; } ``` ## 使用collection的[map](/collections/map.md)和[implode](/collections/implode.md)方法 ``` $messages = [ 'Should be working now for all Providers.', 'If you see one where spaces are in the title let me know.', 'But there should not have blank in the key of config or .env file.' ]; $comment = collect($messages)->map(function($message){ return '- ' . $message; })->implode("\n"); dd($comment); ```