Php 确保txt文件具有特定的文本

Php 确保txt文件具有特定的文本,php,Php,我有这个剧本: $counter=file\u get\u contents(strtolower($\u get[“username”]).“.txt”)-1 我希望“1”改为: echo$_GET[“amount”] 如果分配的txt文件.txt中有足够的内容,我希望该脚本能够运行 例如,如果txt文件中有“8”,并且echo$\u GET[“amount”]等于7,txt文件中有足够的内容。但是如果txt文件中有“6.05”,并且echo$\u GET[“amount”]等于7,txt文件

我有这个剧本:

$counter=file\u get\u contents(strtolower($\u get[“username”]).“.txt”)-1

我希望“1”改为:

echo$_GET[“amount”]

如果分配的txt文件
.txt
中有足够的内容,我希望该脚本能够运行

例如,如果txt文件中有“8”,并且
echo$\u GET[“amount”]等于7,txt文件中有足够的内容。但是如果txt文件中有“6.05”,并且
echo$\u GET[“amount”]等于7,txt文件中没有足够的内容


我如何才能做到这一点?

金额作为参数传递到url中,它应该是这样的:

<a href="http://example.com/path?username=jhon&amount=1"></a>
                                               ^^^^^^^^
$counter = file_get_contents(strtolower($_GET["username"]).".txt") - $_GET["amount"];

if ($counter > 0) {
    // file has enough
} else {
    // file doesn't has enough
}
然后你可以得到这样的金额:

<a href="http://example.com/path?username=jhon&amount=1"></a>
                                               ^^^^^^^^
$counter = file_get_contents(strtolower($_GET["username"]).".txt") - $_GET["amount"];

if ($counter > 0) {
    // file has enough
} else {
    // file doesn't has enough
}

你在哪一部分有问题?这个问题听起来很基本。首先,发布你的代码,其次,什么?你能重新写下你的问题来直接解决这个问题吗?你是在尝试比较两个字符串吗?你在使用一个文本文件数据库吗?听起来是个坏主意。所以你基本上想知道你是否得到了[“数量”]旁注:你没有使用实际数据库做这件事有什么特别的原因吗?文本文件需要大量工作。不客气,可互换是什么意思?例如,
$amount=6
如果($counter>0){
,它们可以更改为4.5或2.05(用户名相同)。