Jump to content

Recommended Posts

Hi all,

 

 

How can i unreverse or double-reverse the following script? I want the script to read from a text file but with the ID going up not down.

 

 

	function display(){
	global $EXHIBIT_ITEM, $EXHIBIT_LIST, $JAVASCRIPT;
	$CODE_URL = exhibit_CODE_URL;

	$view = '';
	$items = '';
	$itemId = count($this->exhibit) + 1;

	// ORDER IN REVERSE
	reset( $this->exhibit );
	foreach( array_reverse($this->exhibit) as $n ){
		$itemId--;
		if( $this->isLoggedIn() ){
			$editLinks = <<<EOT
<A HREF="#" ONCLICK="exhibit_ShowElement('exhibit-edit-$itemId'); exhibit_HideElement('exhibit-view-$itemId'); return false;"><b>Edit</b></A> | 
<A HREF="$CODE_URL?exhibit_action=delete&id=$itemId" ONCLICK="return confirm('Are you sure you want to delete this exhibition item?')"><b>Delete</b></A>
EOT;
			}
		else {
			$editLinks = '';
			}

		$formExhibition = htmlentities( $n['exhibition'] );
		$formStartdate = htmlentities( $n['startdate'] );
		$formEnddate = htmlentities( $n['enddate'] );
		$formVenue = htmlentities( $n['venue'] );
		$replaces = array(
			'{EXHIBITION}'			=> $n['exhibition'],
			'{FORM_EXHIBITION}'		=> $formExhibition,
			'{STARTDATE}'			=> $n['startdate'],
			'{FORM_STARTDATE}'		=> $formStartdate,
			'{ENDDATE}'			=> $n['enddate'],
			'{FORM_ENDDATE}'		=> $formEnddate,
			'{VENUE}'			=> $n['venue'],
			'{FORM_VENUE}'			=> $formVenue,
			'{ITEM_ID}'			=> $itemId,
			'{EDIT_LINKS}'			=> $editLinks,
			'{CODE_URL}'			=> exhibit_CODE_URL
			);
		$itemDisplay = str_replace( array_keys($replaces), array_values($replaces), $EXHIBIT_ITEM );
		$items .= $itemDisplay;
		}

Link to comment
https://forums.phpfreaks.com/topic/179748-reversing-a-reversed-array/
Share on other sites

Thanks for your reply Daniel but if i remove the code withing the array_reverse brackets i get an invalid arguement error.

 

I only want to reverse the order of the list as its taken from the file. At the minute it is taking the first entry and putting it last. But i want it to put the first entry in the text file first.

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.