Jump to content

Order a multiple line variable


jonybhi

Recommended Posts

Hello,

I've a text file containing data for images its like:

 

1:thumb_1.gif:large_1.gif

8:thumb_2.gif:large_2.gif

5:thumb_3.gif:large_3.gif

 

Array 0 represent views, Array 1 represents thumbnail and Array 2 represents full size image.

 

I'm using the following code to display images:

 

<?php


$file_handle = fopen("datafile.txt", "rb");
while (!feof($file_handle) ) 
{	
	$line_of_text = fgets($file_handle);
	$parts = explode('/n', $line_of_text);
	foreach($parts as $gallery_data)
	{

		$data = preg_split('/:/', $gallery_data);	
	?>

<img src="<?php echo $data[0]; ?>" width="150" height="150">

	<?php


	}
}
fclose($file_handle);

?>

 

the above code displays the images in text file order. I'd like it to display most viewd image first, for which the data in variable $line_of_text should be:

 

8:thumb_2.gif:large_2.gif

5:thumb_3.gif:large_3.gif

1:thumb_1.gif:large_1.gif

 

so the question is, how can i arrange it?

Link to comment
https://forums.phpfreaks.com/topic/242431-order-a-multiple-line-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.