Jump to content

Array from CSV and POST URL. Help?


hishamomran

Recommended Posts

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);

}
?>

Link to comment
https://forums.phpfreaks.com/topic/223257-array-from-csv-and-post-url-help/
Share on other sites

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.