[SOLVED] write in text file
Posted: Mon Aug 16, 2004 3:41 pm
feyd | Please use
note : print_r($serv_lst[$i]);
echo "</pre>";
give :
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
i want be able to write what i can print_r . But i can't figured out how to do it.Code: Select all
<?
$handle = fopen("wdt_list.csv", "r");
while (!feof($handle)) {
$node_id = fscanf($handle, "%[W0-9] %[A-Za-z]\r\n"); //*find node id
if ($node_id)
{
list ($serv_id) = $node_id;
$serv_id = substr($serv_id, 2, -2); //*format to xxxx serv. format
$serv_tab[] = $serv_id; //*create array
$serv_unk = array_unique ($serv_tab); //* del duplicate
$serv_lst = array_values($serv_unk);
}
$serv_id=NULL;
}
fclose($handle);
$count = count($serv_lst);
for ($i = 0; $i < $count; $i++)
{
echo "<pre>";
print_r($serv_lst[$i]);
echo "</pre>";
}
$fd = 'lstserv.txt';
$text = ???????;//$text insert in text file
if (is_writable($fd)) {// check if text writable
if (!$handle = fopen($fd, 'w+')) {//w+ size to 0 and read write
echo "can't open ($fd)";
exit;
}
if (fwrite($handle, $text) === FALSE) {// write in the file
echo "can't write ($fd)";
exit;
}
echo " success;can write($text) in ($fd) ";
fclose($handle);
} else {
echo "the file $fd can't be write.";
}echo "</pre>";
give :
Code: Select all
1046
1041
1018
1015
1013
1011feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]