Creating a PHP array from the contents of a file -


i have php file contains text in following format.

line 1 -   "title","url","imgurl","tags" line 2 -   "title","url","imgurl","tags" line 3 -   "title","url","imgurl","tags" 

it structured database each line record , 1st set of "" title. 2nd set of "" url, etc.... line line.

i'm not experienced programmer stretch of imagination. best way create array contents of file?

i've tried following, didn't work.

$content = array(file_get_contents("path/content.php")); 

i believe need update structure of data , method use create array, i'm not sure how. appreciated.

i want able retrieve title, url, imgurl, or tags line of text, don't know how express in array format.

i think want able request $content[0][1] url line1 , $content[1][3] tags line2.

$file = fopen("path/content.php", "r"); while($content[] = fgetcsv($file, 1000, ",")); 

you should able access each element specified:

echo $content[0][1]; // echos first line, url 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -