gaptrast
Member
- Messages
- 123
- Reaction score
- 0
- Points
- 16
Hello,
I have a problem with my flat file database...
they are built like this:
With the code I want the strings before the : shall be variable names and the string after shall be the value. THen I can use it like this:
Do you understand?? Here is my code that is nearly working::
The only problem is that the $image array (or any other array) will not work!! I can figure out what I do wrong. Thanks for any help
I have a problem with my flat file database...
they are built like this:
Code:
title:BLALBL
brief:Cool thing
thing:asdf
image[0]:http://....
image[1]:http://....
With the code I want the strings before the : shall be variable names and the string after shall be the value. THen I can use it like this:
PHP:
<?php
echo $title;
echo "<p>$brief</p>";
echo"<img src='$image[0]' />";
echo"<img src='$image[1]' />";
?>
Do you understand?? Here is my code that is nearly working::
PHP:
<?php
$file = file("../../txt/datafile.txt");
foreach ($file as $line_num => $line){
${"t".$line_num}=explode(":",$file[$line_num]);
// creating arrays ($t0,$t1,$t2 ...)
$${"t".$line_num}[0] = ${"t".$line_num}[1];
?>
The only problem is that the $image array (or any other array) will not work!! I can figure out what I do wrong. Thanks for any help