Hi, I am trying to save one variable from flash, using php to write the variable to a text file.
The text file has 4 variables per row which is first read into flash, but I only want to save to the last variable.
Here is the text file :
&link0=google&url0=http://www.google.com&count0=0
&link1=yahoo&url1=http://www.yahoo.com&count1=0
&link2=realitydesigns&url2=http://www.realitydesigns.co.uk&count2=0
&link3=actionscript.org&url3=http://www.actionscript.org&count3=0
&link4=kirupa&url4=http://www.kirupa.com&count4=0
&finished=okay&
Here is the php file I am using at the moment (which just over writes the whole lot in the text file!)
<?php
$fd = fopen("counter.txt", "w");
fwrite($fd, "count=$count");
fclose($fd);
?>
I have had a little help from one of the flash forums. one guy reccomends using this code, But I don't know how to implement it!
// set filename
$filename = "test.txt";
// read file into array
$contents = file($filename);
// get array length
$length = sizeof($contents);
// display each line with "for" loop
for($counter=0; $counter<$length; $counter++) {
for ($tmp=0; $tmp<2; $tmp++) {
// Use preg_replace here ???
}
}
This is part of the code - he reccomended this to finish it - "What you now need to do is use a regular expressions search to find antyhing that says "countX=XXX" where the X's are varialbe, and replace it with the appropriate new count."
If this makes sense, can someone help me out!
Thanks
deef