Jump to content


Photo

remove last character from a string


  • Please log in to reply
2 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 20 September 2006 - 01:08 PM

How can i remove the last character from a string before displaying
http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 20 September 2006 - 01:13 PM

<?php
$str = substr($str, 0, strlen($str) - 1);
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 20 September 2006 - 01:15 PM

or:

$str = substr($str, 0, -1);



:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users