다음 코드를 사용하면 특정 배열 행과 부분 배열 행으로 이동하여 그 값을 변경할 수 있습니다.배열의 각 부분 배열에 저장된 값을 편집하십시오.
그러나 내가해야 할 일은 모든 행의 첫 번째 열을 BLANK 또는 NULL로 변경하거나 삭제하는 것입니다.
어떻게 이것을 수행하기 위해 아래 코드를 변경할 수 있습니까?
<?php
$row = $_GET['row'];
$nfv = $_GET['value'];
$col = $_GET['col'];
$data = file_get_contents("temp.php");
$csvpre = explode("###", $data);
$i = 0;
$j = 0;
if (isset($csvpre[$row]))
{
$target_row = $csvpre[$row];
$info = explode("%%", $target_row);
if (isset($info[$col]))
{
$info[$col] = $nfv;
}
$csvpre[$row] = implode("%%", $info);
}
$save = implode("###", $csvpre);
$fh = fopen("temp.php", 'w') or die("can't open file");
fwrite($fh, $save);
fclose($fh);
?>
(일반적으로 정규식을 위해 또한 좋은 사이트) Regex Tutorial - Lookahead and Lookbehind Zero-Width Assertions 참조 열. 이제 해결되었습니다. – Artelius
또한 첫 번째 배열 요소를 잘라내는데 신경 쓰지 않는다면 $ row [0]이 원래 $ row [1]이었던 것을 참조하도록하고,'array_shift ($ row)'를 수행하면됩니다. – Artelius
설명하지 않고 downvote 누가 이러한 농담하는 사람있어? – Artelius