hishamomran Posted January 3, 2011 Share Posted January 3, 2011 I seem to be having a problem with this code. It's supposed to parse the file info.txt and explode comma separated values into an array and then add each value from that file to the end of a URL and POST that url. What I'm getting now is just the first number in the array. Anyway, here's the code: <?php $FileName = "info.txt"; $FileHandle = fopen($FileName,"r"); $FileContent = fread ($FileHandle,filesize ($FileName)); fclose($FileHandle); // You can replace the \t with whichever delimiting character you are using $SplitContent = explode("\t", $FileContent); foreach($SplitContent as $CurrValue) { header('Location: http://website.com/file.php?value=' . $CurrValue); } ?> Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 3, 2011 Share Posted January 3, 2011 1. your code is spliting the content based upon tabs not commas 2. redirecting via header in your loop will result in only the first element of the array being processed Quote Link to comment Share on other sites More sharing options...
hishamomran Posted January 3, 2011 Author Share Posted January 3, 2011 Yeah I know about the tabs part, but why is the loop parsing only my first result? How would I go about changing that? Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 3, 2011 Share Posted January 3, 2011 it depends upon what your goal is. Quote Link to comment Share on other sites More sharing options...
hishamomran Posted January 4, 2011 Author Share Posted January 4, 2011 http://website.com/file.php?value=12345 This link is used to submit the value as a phone number and a SMS is sent to that number. What I'm trying to do here is automate the bulk sending of one SMS to multiple numbers. So I load the phone number from the text file and append each phone number to the end of the URL so that the URL is submitted, the SMS is send, and then moves on to the next URL. Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 4, 2011 Share Posted January 4, 2011 this may be of assistance... You cannot pass an array through a url in it's raw form. You have to serialize it, encode it, then on the receiving page you unencode it, and finally unserialize it. Example: <? $test = array(1,2,3,4); $serialized = rawurlencode(serialize($test)); echo "<a href=receive_array.php?testvar=".$test.">Test</a>"; ?> then in recieve_array.php: <? $testvar = unserialize(rawurldecode($_GET['testvar'])); echo "<pre>"; print_r($testvar); echo "</pre>"; ?> source: http://www.justskins.com/forums/passing-array-in-the-120375.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.