file-get-contents - 来自文本输入的 php file_get_contents
问题描述
使用下面的代码从文本文件生成随机行。有没有办法通过用户文本输入设置文本文件的 url?对不起,完全的菜鸟
<?php
$text = file_get_contents('https://mytextfileurl.com');
$textArray = explode("\n", $text);
$randArrayIndexNum = array_rand($textArray);
$randPhrase = $textArray[$randArrayIndexNum];
?>
解决方案
推荐阅读
- php - 是否可以有动态封面?
- angular - 如何在anyChart的甘特图中删除额外的分隔线
- haskell - 为什么在 Liquid Haskell 中 Nat 类型等于 Int?
- reactjs - Ctx.db.mutation."updateAccepted" 不是函数.. Prisma 不会生成突变
- r - 具有多个条件和 OR 的 dplyr 过滤器
- python - 如何减去变量
- javascript - 如果我更改了数字输入的格式,闪亮的书签不起作用
- php - 如何在 sql server 上的列名称为阿拉伯语时获取数据?
- terraform - 有没有办法将多个角色附加到单个策略?
- c++ - 使用 Armadillo C++ 加载稀疏矩阵