Jump to content

Archived

This topic is now archived and is closed to further replies.

vidyashankara

Trim a String.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Use the [a href=\"http://www.php.net/substr\" target=\"_blank\"]substr()[/a] function.

Ken

Share this post


Link to post
Share on other sites
substr()

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

Share this post


Link to post
Share on other sites
[code]
<?


$fifth[$i]='HET0124324';

$fifth[$i]=$result;

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

echo $fifth_result;

?>
[/code]


or

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.