hi
I been working on a little snippet of code <about the level of my skill>
The idea i trying to work out is
I have a text file which i open, it has the heading id,image,link,desc and the value are separated by commas, I then load them in to a multi dimension array
Create a random number and select the appropriate id in the array, then do this again and make sure that they are not the same, if that is ok then load the results of each element in to variable so i can then manipulate in my code
I been playing with bits of code and so far got this
<?php
// the HTML source of a URL.
$lines = file('textfile.txt');
//total lines available
$limit = count($lines);
//get the keys/headers
$headers = explode(",",$lines[0]);
//to store the data
$ListItems = array();
// Loop through array to extract data
for($i=1; $i < $limit; ++$i)
{
//extract the values
$values = explode(",",$lines[$i]);
//create temporary array
$temp = array();
//store the values
for( $j=0, $inner_limit=count($values); $j < $inner_limit; ++$j)
{
$temp[ $headers[$j] ] = $values[$j];
}
//append to "master array"
$ListItems[]=$temp;
}
// count how many rows are in the ray
$NoListElements=count($ListItems)-1;
echo "Elements " .$NoListElements. "<br />";
//reset random nos
$randomID1=0;
$randomID2=0;
// get random number 1
$randomID1 = mt_rand(1,$NoListElements);
// testing to ensure get 2nd random number which is not the same
while($randomID2 == 0)
{
$randomID2 = mt_rand(1,$NoListElements);
if ($randomID2 == $randomID1) $randomID2 = 0 ;
}
// Display values
echo "Random 1 =" .$randomID1;
echo "<br/>";
echo "Random 2 =" .$randomID2;
echo "<br/>";
//Need to get the row element for random id 1 from ListItems
<help needed here>
//Need to get the row element for random id 2 from ListItems
<help needed here>
but i not too sure how to get any further
if you can explain how i would put these in to a variable and also how if i can just access them direct to put in to my html code .. ie echo i presume !!!
thanks for the missing links