Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php数组+;html中的字符串?_Php_Html_Arrays_Postgresql_Plpgsql - Fatal编程技术网

如何使用php数组+;html中的字符串?

如何使用php数组+;html中的字符串?,php,html,arrays,postgresql,plpgsql,Php,Html,Arrays,Postgresql,Plpgsql,我正在使用PHP中的PL/pgsqlRETURNS TABLE获得下面的输出 array(4) { [0]=> array(1) { ["not_actual_values"]=> string(88) "("var1","var2",var3,var4,date1,int,int,int,var5,int,int,int,int)" } [1]=> array(1) { ["not_actual_values"]=> string(89) "("

我正在使用PHP中的PL/pgsql
RETURNS TABLE
获得下面的输出

array(4) { 
[0]=> array(1) 
    { ["not_actual_values"]=> string(88) "("var1","var2",var3,var4,date1,int,int,int,var5,int,int,int,int)" } 
[1]=> array(1) 
    { ["not_actual_values"]=> string(89) "("var1","var2",var3,var4,date1,int,int,int,var5,int,int,int,int)" } 
[2]=> array(1) 
    { ["not_actual_values"]=> string(88) "("var1","var2",var3,var4,date1,int,int,int,var5,int,int,int,int)" } 
[3]=> array(1) 
    { ["not_actual_values"]=> string(89) "("var1","var2",var3,var4,date1,int,int,int,var5,int,int,int,int)" } 
}
我无法在HTML中使用上述输出。我尝试使用php explode,但没有成功,因为我得到了零数组。另外,让我困惑的是,我在前两个变量中得到了引号,而在其他变量中没有

更新

我使用了下面的函数,但得到了零数组


我如何才能做到这一点?

您的内部值是数组,而不是字符串,您需要考虑这一点:

function pgArraytoPhp($array) {
     foreach ($array as $row) {      // $row is an inner array here!
         actuallyDoParsing($row[0]); // Parse row's first element, 
                                     // which will be the string you want.
     }
}

根据需要,您将返回所有这些
实际运算()调用的累积结果。

这是我得出的答案。虽然它不整洁,但现在看起来像预期的那样工作

$fetch=pg_fetch_all($query); //fetching data from postgresql
$count=count($fetch);
for ($j=0;$j<$count;$j++) {
$a = $fetch[$j]['not_actual_values'];
$b = array(explode("," , $a)); 
$count2=count($b[0]);
foreach ($b as $f) { echo '<tr>';
for ($i=0;$i<$count2;$i++){
echo '<td><input type="text" readonly value='.$f[$i].'>';
}   }   }
$fetch=pg\u fetch\u all($query)//从postgresql获取数据
$count=计数($fetch);

对于($j=0;$j请让您的代码更易于阅读。就像1命令的新行一样,请共享您的代码。不可能知道您做错了什么。我需要在html表中使用上述输出。我需要在单独的列中使用每个变量。现在我将它们放在一列中。由于CSV.PHP有一个函数,解析您的“值”字符串可能更可靠对于这一点,您可能会发现它很有用:。我还没有尝试过。等等,您正在尝试解码
var\u dump()
output?为什么?
$fetch=pg_fetch_all($query); //fetching data from postgresql
$count=count($fetch);
for ($j=0;$j<$count;$j++) {
$a = $fetch[$j]['not_actual_values'];
$b = array(explode("," , $a)); 
$count2=count($b[0]);
foreach ($b as $f) { echo '<tr>';
for ($i=0;$i<$count2;$i++){
echo '<td><input type="text" readonly value='.$f[$i].'>';
}   }   }