Jump to content


Photo

Trim a String.


  • Please log in to reply
3 replies to this topic

#1 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 13 June 2006 - 02:36 AM

Lets say i have an Array $fifth

Now $fifth[$i]='HET0124324';

How do i trim this number to get only the first four digits?
I want just HET0, How do i do that?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 13 June 2006 - 03:08 AM

Use the [a href=\"http://www.php.net/substr\" target=\"_blank\"]substr()[/a] function.

Ken

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 13 June 2006 - 03:08 AM

substr()

[a href=\"http://www.php.net/substr\" target=\"_blank\"]http://www.php.net[/a]
~ D Kuang

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 June 2006 - 05:09 AM

<?


$fifth[$i]='HET0124324';

$fifth[$i]=$result;

$fifth_result=substr($result, 0, 4);

echo $fifth_result;

?>


or

echo substr($fifth[$i], 0, 4);

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users