Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.