在PHP内爆时无效的参数 [英] invalid argument when imploding in php

查看:101
本文介绍了在PHP内爆时无效的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

进出口运行以下code时收到无效参数错误。我试着去改变 $信息排列在一条线上的值,然后破灭了,破灭其父数组,然后保存整个家当回到它从何而来。

  $行pre = $ _GET ['行'];
$ newfieldvalue = $ _GET ['NFV'];
$行= - $行pre;
$数据=的file_get_contents(temp.php);
$ CSV pre =爆炸(###,$数据);
$ I = 0;
    的foreach($ CSV pre $ AS键=> $值){
    $ I ++;
    如果($ i = $行){
    $信息=爆炸(%%,$值);
    $信息[$目标] = $ newfieldvalue;    $preSAVE =破灭(%%,$信息);
    }
    }
$保存=破灭(###,$preSAVE);
$跳频=的fopen(temp.php,W)或死亡(无法打开文件);
FWRITE($ FH,$保存);
FCLOSE($ FH);

下面的更新

  $行pre = $ _GET ['行'];
$ newfieldvalue = $ _GET ['NFV'];
$目标= $ _GET ['目标'];
$行= - $行pre;
$数据=的file_get_contents(temp.php);
$ CSV pre =爆炸(###,$数据);
$ I = 0;
    的foreach($ CSV pre $ AS键=> $值){
        $ I ++;
        如果($ I $ ==行){
            $信息=爆炸(%%,$值);
            $信息[$目标] = $ newfieldvalue;            $ CSV pre [$关键] =破灭(%%,$信息);
        }
    }
$保存=破灭(###,$ CSV pre);
$跳频=的fopen(temp.php,W)或死亡(无法打开文件);
FWRITE($ FH,$保存);
FCLOSE($ FH);

目标是字段,我希望与newfieldvalue数据更新所选行内。


解决方案

  

$保存=破灭(###,$preSAVE);


在这一点上,<​​code> $preSAVE 是一个字符串,而应该是一个阵列内爆工作。创建你的地方推$preSAVE值的数组,内爆的那一个。

Im getting invalid argument error when running the following code. Im trying to change the value of a line in the $info array, then implode it, implode its parent array, and then save the whole shebang back to whence it came.

$rowpre = $_GET['row'];
$newfieldvalue = $_GET['nfv'];
$row = --$rowpre;
$data = file_get_contents("temp.php");
$csvpre = explode("###", $data);
$i = 0;
    foreach ( $csvpre AS $key => $value){
    	$i++;
    	if($i = $row){
    		$info = explode("%%", $value);
    		$info[$target] = $newfieldvalue;

    		$presave = implode("%%", $info);	
    	}			
    }


$save = implode("###", $presave);
$fh = fopen("temp.php", 'w') or die("can't open file");
fwrite($fh, $save);
fclose($fh);

update below

$rowpre = $_GET['row'];
$newfieldvalue = $_GET['nfv'];
$target = $_GET['target'];
$row = --$rowpre;
$data = file_get_contents("temp.php");
$csvpre = explode("###", $data);
$i = 0;
    foreach ( $csvpre AS $key => $value){
        $i++;
        if($i == $row){
            $info = explode("%%", $value);
            $info[$target] = $newfieldvalue;

            $csvpre[$key] = implode("%%", $info);  
        }           
    }


$save = implode("###", $csvpre);
$fh = fopen("temp.php", 'w') or die("can't open file");
fwrite($fh, $save);
fclose($fh);

Target is the field within the selected Row that i wish to update with the newfieldvalue data.

解决方案

$save = implode("###", $presave);

At that point, $presave is a string, and should be an array to work with implode. Create an array where you push the $presave-values, and implode that one.

这篇关于在PHP内爆时无效的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆