Page 1 of 1

Excluding Part of a Variable

Posted: Wed Sep 10, 2003 11:56 am
by bbeavis123
I am using this to create a link to a php page:

zenoview.php?m=<?php echo $m; ?>&c=<?php echo $c; ?>

Next I want to add to the M variable in order to call a different set of images and text (see where I have added the _mt) :

zenoview.php?m=<?php echo $m; ?>_mt&c=<?php echo $c; ?>

This adds _mt to the M (model # variable) which in turn calls the existing variable with _mt added to it.

Now I need to figure out how to subtract that _mt addition on the next page using the same echo function since now the echo $m being used on that page will now be including the _mt within it.

In short, how do I subtract or exclude a portion of a variable?
Example...if m=123456_x and i want to use the function above to call it without the _x at the end.

Posted: Wed Sep 10, 2003 12:08 pm
by JayBird

Code: Select all

$var = substr($var,0,-2);
will remove the last 2 character of a varaible

Posted: Wed Sep 10, 2003 12:54 pm
by bbeavis123
Thanks!

This works perfectly.