heres what I did:
Code: Select all
<?php
$entry_a=($entries[0][entrymsg]);
trim($entry_a);
print($entry_a);
print("hello");
?>gives output of
Code: Select all
here goes the first message.
helloif anyone knows how to get rid of that please let me know..
Background:
why?
well.. I need to use my php array data in a javascript array and the line break really messes things up...
see example below:
Code: Select all
namї9] = "here is the first message
";
namї10] = "hello";the text file itself where the php array feeds from has all the elements on a separate lines.
Trollll helped me write code to put my text file contents into an array, which I have also included..
the topic where that was discussed is here:
http://www.devnetwork.net/forums/viewtopic.php?t=10951
and full code for that was
Code: Select all
<?php
$fileContents = file("blog.txt");
$entries = array();
for ($i = 0; $i < count($fileContents); $i += 5) {
array_push($entries, array("entrynum" => $fileContents[$i], "entrymsg" => $fileContents[$i + 1], "entrycolor" => $fileContents[$i + 2], "entrydate" => $fileContents[$i + 3]));
}
?>my data entry is done via forms and a php form handler..
code for that is:
Code: Select all
<?php
@extract($_POST);
if(is_writable('blog.txt'))
{
$fp = fopen('blog.txt','a');
$content = "\n$entrynum\n$entrymsg\n$category\n$entrydate\n";
fwrite($fp,$content);
fclose($fp);
echo'Successfully written entry';
}
else
{
echo'File is not writable';
}
?>