EagerWolf Posted February 3, 2007 Share Posted February 3, 2007 I have got file which includes array... I would like to add new things to array... I have got form ... user must enter key and value ... Than I have got a code.. function add($var1, $var2) { include('tmp.php'); $filename = 'test.php'; $fh = fopen($myFile, 'w'); if(array_key_exists($var1, $myarray)) { print "Napaka, v arrayu je ze zapis z enakim kljucem"; } else { $temp_var = array ( $var1 => $var2, ); $temp_array = array_merge($slovenski, $temp_var); if (is_writable($filename)) { echo "TRUE"; } foreach ($temp_array as $key => $value) { $stringData = $key; fwrite($fh, $stringData); } fclose($fh); } } I get warning: Warning: fwrite(): supplied argument is not a valid stream resource in ... I set test.php to 777... Also check if file is writable returns true. I've tried to print_r my new array and it is working just great... So there must be a problem with fwrite! Can u help me... Best regards, Matija Link to comment https://forums.phpfreaks.com/topic/36854-add-new-line-to-array/ Share on other sites More sharing options...
Hypnos Posted February 3, 2007 Share Posted February 3, 2007 Change this: $fh = fopen($myFile, 'w'); To: $fh = fopen($filename, 'w'); Link to comment https://forums.phpfreaks.com/topic/36854-add-new-line-to-array/#findComment-175841 Share on other sites More sharing options...
EagerWolf Posted February 3, 2007 Author Share Posted February 3, 2007 LoL 10x I was searching for error all around but not there Link to comment https://forums.phpfreaks.com/topic/36854-add-new-line-to-array/#findComment-176027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.