php - Using text from a file to point to another file to read -
note: i'm sorry if title little unclear couldn't think of way put it.
i making php posting system blog website. have file called posts.txt has information points other text files. these other text files have physical post content in them. know not best way i'm doing.
a sample of posts.txt:
posts/topdownshooter.txt posts/leapmotionsandbox.txt end
the first 2 lines point other text files contain post content. last line "end" lets program know post "pointers" done
here sample of post topdownshooter.txt
programming top down shooter actual post content goes here end
the first line tag organization. second line title of post. , third actual content. last line serves same purpose.
here php code: use "<--" comments
<?php $posts = "posts/posts.txt"; <--pointer location of posts.txt $postslines = file($posts); $fetchingpost = true; <--for while loop $postnumber = 0; $postpointer; <--in example of posts.txt second or third line $posttag; $posttitle; $postcontent; $endcondition = "end"; while ($fetchingpost == true) { $endoffile = strcmp($postslines[$postnumber], $endcondition); if ($endoffile == 0) { $fetchingpost = false; } if ($endoffile <> 0) { $postpointer[$postnumber] = $postslines[$postnumber]; $posttag[$postnumber] = file($postpointer[$postnumber]); <--the problem, see below $postnumber = $postnumber + 1; } } ?>
the problem: not let me use line take out of posts.txt "pointer" accessing topdownshooter.txt or that. thought value pulling out of posts.txt string not. there anyway can convert string or make work?
edit:
in short:
is there anyway take $postslines = file("somerandomtxtfile.txt); , make %postslines[0] string?
i'm not sure if understand question, i'd try replacing line this
$posttag[$postnumber] = file_get_contents($postpointer[$postnumber]);
answering question in edit, can this:
$postlines = explode(php_eol, file_get_contents("somerandomtxtfile.txt"));
Comments
Post a Comment