I have a text file which has a few hundred lines of data, all in a similar format.
Essentially there is 5 fields of data, and they are separated by spaces. Unfortunately, some of the fields contain spaces so I am trying to work around how to extract, say, the 3rd field of data.
This 3rd field will always be one of about 24 known values. So I've created a database table which has the known values along with a new value - called 'ID' and has no spaces.
My intention is to run a str_replace() function and supply it with an array of all the strings to find, along with an array of all the strings to use in the replace, and of course an individual line from my file (perhaps I could do the whole file in one go !).
str_replace($find_array, $replace_array, $line_txt);
What I'd like to do is write a function that returns the arrays at the beginning of the script, and I can then use those arrays at the suitable moment in the script.
Can anyone advise on how I should create the arrays and return them from a function, currently I receive an error that says:
Fatal error: Cannot use [] for reading in /home/g/p/gpbdreamteam/public_html/dt_update.php on line 40
and line 40 reads
return $team_name_array[];