I am running a local Applescript on my Mac that calls a php file to do some faster calculations. The php file has some arrays listed, like this:
$blackList = array(
'Bob Haskinson',
'Janet Vice',
'Howard Borderly',
)
I have a text file that's regularly generated with a list of names that I have to manually copy and paste into the PHP file each time it changes. This text file is already formatted like this:
'Bob Haskinson',
'Janet Vice',
'Howard Borderly',
'David Jadhurski',
I know how to use server side includes in a PHP page on a web server, and I know how to include a local file in an Applescript, but so far I can't get this example to work.
Based on the searches I made, I figured "file" would work. I found a lot of examples that pertain to Windows and Unix, and I double-checked how to write file paths on a Mac. I've tried the following (and several variants) but they all failed:
$blackList = file('/Users/derwood/Dropbox/Caps/Daily/Blacklist.txt');
$blackList = array('/Users/derwood/Dropbox/Caps/Daily/Blacklist.txt');
I haven't found anything pertaining to this situation in a few days of searching, but I may not be looking for the right keywords.
You need to write a function in php which collects the data from text file into array format in a php variable like this..
$variable = file_get_contents('your text file');
$data = explode(',',$variable);
Now the $data will contain the array of data that can be used in your apple script.