Jump to content

Recommended Posts

hi, i am using  a dynamic folderlist-script in a gallery and it works fine so far.

 

but i do not get it (i am no coder i admit it) how to avoid the first two letters of a dir by using substr method.

 

here is my gallery script which works well except that i would like to prevent folders showing their numbers like 01 at the beginning..:

 

if (isset( $_GET['galerie'] ) )
		{
			echo '<div id="container"><div class="main-content">
				<div style="width:auto;white-space:nowrap;height:530px;background:#585850;position:relative;"><div id="preview">';
			$bilder = glob( "sets/{$_GET['galerie']}/images/*.jpg" );
			natsort( $bilder );
			foreach ($bilder as $bild)
			{
				$bild = array_pop( explode( "/", $bild ) ); // where to put substr function?

				echo '<img src="sets/' .$_GET['galerie']. '/images/' .$bild. '" style="margin-right:2px;"/>';

			}
			echo '</div></div></div>';
		}

 

thanx a lot for any help in grammar for beginners.. :-\

hi, my first post was with wrong code, sorry!!

 

maybe now somebodey can help:

 

i wonder how to avoid the first two letters of a dir by using substr method.

 

here is my gallery script which works well except that i would like to prevent folders showing their numbers like 01 at the beginning..:

 


	<?php
	// Galerien ermitteln
	$verzeichnisse = glob( "sets/*", GLOB_ONLYDIR );
	echo '<div id="nav"><ul>';
	foreach ($verzeichnisse as $dir)
	{
		$dirname = array_pop( explode( "/", $dir ) ); // where do i put substr function?

		echo '<li><a href="' .$_SERVER['PHP_SELF']. '?galerie=' .$dirname. '">' .$dirname. '</a></li>';
	}
	echo '</ul><ul><li><a href="main.php">Main</a></li></ul></div><br class="clear" />';
	?>

 

thanx a lot for any help in grammar for beginners..  ???

I do not see where you attempted to do that code.

 

$dirname = substr($dirname, 2);

 

Should remove the first 2 items from the name.

 

EDIT:

Beaten to it, but a correction was needed. Should be 2 not 1.

 

oh yeah =\..

 

0 would be from the start

 

1 would be after the first, sorry bro :) premiso is right :P

thanks a lot everyone here, meanwhile i came up with even another idea from a pityful friend and now it looks like this:

	<?php
	// Galerien ermitteln
	$verzeichnisse = glob( "sets/*", GLOB_ONLYDIR );
	echo '<div id="nav"><ul>';
	foreach ($verzeichnisse as $dir)
	{
		$dirname = array_pop( explode( "/", $dir ) ); 

		// $dir=substr($dir, 2); << wrong idea.. !

		// better idea..:
		echo "<li><a href=".$_SERVER['PHP_SELF']."?galerie=".$dirname.">".substr($dirname,2)."</a></li>"; 
	}
	echo '</ul><ul><li><a href="main.php">Main</a></li></ul></div><br class="clear" />';
	?>

 

again thank you so much, you've been very kind!

 

 

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.