url string change

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NickStrong
Forum Newbie
Posts: 2
Joined: Tue Aug 09, 2011 12:18 pm

url string change

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: url string change

Post by Celauran »

Code: Select all

$region2burl = substr($region2burl, 1);
or am I missing something here?
NickStrong
Forum Newbie
Posts: 2
Joined: Tue Aug 09, 2011 12:18 pm

Re: url string change

Post 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.
Post Reply