首页 > 解决方案 > 来自文本输入的 php file_get_contents

问题描述

使用下面的代码从文本文件生成随机行。有没有办法通过用户文本输入设置文本文件的 url?对不起,完全的菜鸟

<?php
$text = file_get_contents('https://mytextfileurl.com');
$textArray = explode("\n", $text);    
$randArrayIndexNum = array_rand($textArray);    
$randPhrase = $textArray[$randArrayIndexNum];
?>

标签: file-get-contents

解决方案


推荐阅读