Php 显示内容柱
我想显示Php 显示内容柱,php,javascript,jquery,Php,Javascript,Jquery,我想显示POST变量的内容,但我的输出是空的 <?php $dir = '/var/www/devData/test'; // create new directory with 777 permissions if it does not exist yet // owner will be the user/group the PHP script is run under if ( !file_exists($dir) ) { mkdir ($dir, 0777);
POST
变量的内容,但我的输出是空的
<?php
$dir = '/var/www/devData/test';
// create new directory with 777 permissions if it does not exist yet
// owner will be the user/group the PHP script is run under
if ( !file_exists($dir) ) {
mkdir ($dir, 0777);
}
$stringData = print_r($_POST['data'], true);
$file = "/var/www/devData/test/ciao.txt";
$fh = fopen($file, 'a+') or die("can't open file");
$fla = 0;
$arr = array();
$i = 0;
while(!feof($fh)) {
$theData = fgets($fh, filesize($file));
array_push($arr,$theData);
//echo $arr[$i];
$i++;
}
echo $stringData;
fclose($fh);
?>
其中options\u label
是一个数组
我尝试使用
解码\u json
等等,但是$stringData
仍然是空的。我认为问题在于:
$stringData = print_r($_POST['data'], true);
如果要在file.txt中存储$\u POST的内容,应将$\u POST['data']转换为如下字符串:
$stringData = "";
foreach ($_POST['data'] as $key=>$val) {
$stringData .= $key . ": " . $val . "\n\r";
}
变量$stringDataBut的内容,这就是为什么我问。。。你所说的“contenute”是什么意思?我想知道类似contenute的字符串,因为当我写入文件时,字符串的contenute被正确存储,并且是以下形式:90;冷漠的0.16;0.35;-0.01;0.3;0.25;0.32;注意2件事:1)在
循环时,实际上并没有修改$stringData
,只是更改$arr
;2)递增$i
是无用的,因为循环不依赖$i
的值来停止。我知道;)字符串将在Matt之后进行操作。我可以将$stringData的内容存储到文件中。我只想显示它,并在输出仍然为NULL后进行操作。我不确定是否可以提供任何帮助。对不起,伙计。
$stringData = "";
foreach ($_POST['data'] as $key=>$val) {
$stringData .= $key . ": " . $val . "\n\r";
}