Page 1 of 1

url string change

Posted: Tue Aug 09, 2011 1:09 pm
by NickStrong
I trust you'll see from below that field values are taken and before use/display the first letter is removed. This first letter is an ordering attribute.
Also, field values 'names' are transformed into lower case and spaces transformed into hyphens, to be used as urls.

Code: Select all

        	<?php $region = get_post_meta($property_id, 'region', $single); ?>
        	<?php $region2 = get_post_meta($property_id, 'region2', $single); ?>
        	<?php $capacity = get_post_meta($property_id, 'capacity', $single); ?>
        	<?php $class = get_post_meta($property_id, 'class', $single); ?>

<!-- change name to lower case, change spaces to hyphens, for url use -->
        	<?php $regionurl = strtolower($region[0]);?>
        	<?php $region2aurl = strtolower($region2[0]);?>
        	<?php $region2burl = strtr($region2aurl," ","-");?>

<!--  REMOVE FIRST, ORDERING, LETTER FROM URL - HOW ?? -->

<!--  remove first, ordering, letter from name -->
		<?php $class9[0] = ltrim($class[0],"a..z");?>
		<?php $region9[0] = ltrim($region[0],"a..z");?>
		<?php $region29[0] = ltrim($region2[0],"a..z");?>

        	<?php echo "Category : $class9[0]"; ?>
        	<br/>
        	<?php echo "Location : <a href='http://www.french-waterways.com/region/$region2burl.html/'>$region9[0]</a>"; ?>
        	<br/>
        	<?php echo "Region : $region29[0]"; ?>
        	<br/>
        	<?php echo "Capacity : $capacity[0]"; ?>

What I need to do as well, is to remove that initial character from the url string.
I've tried applying the same technique, but it doesn't produce the correct result.
Any suggestions very gratefully received. This is my first foray into php . .
Thanks

Re: url string change

Posted: Tue Aug 09, 2011 1:13 pm
by Celauran

Code: Select all

$region2burl = substr($region2burl, 1);
or am I missing something here?

Re: url string change

Posted: Tue Aug 09, 2011 2:21 pm
by NickStrong
Great - I am v. grateful. Looks like its a simple, obvious, thing . . but I'm a complete noob. :)
I'm going to chance my arm and post as new threads a couple of related problems I can't get my ignorant head around.