vidyashankara Posted June 13, 2006 Share Posted June 13, 2006 Lets say i have an Array $fifthNow $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? Link to comment https://forums.phpfreaks.com/topic/11832-trim-a-string/ Share on other sites More sharing options...
kenrbnsn Posted June 13, 2006 Share Posted June 13, 2006 Use the [a href=\"http://www.php.net/substr\" target=\"_blank\"]substr()[/a] function.Ken Link to comment https://forums.phpfreaks.com/topic/11832-trim-a-string/#findComment-44835 Share on other sites More sharing options...
poirot Posted June 13, 2006 Share Posted June 13, 2006 substr()[a href=\"http://www.php.net/substr\" target=\"_blank\"]http://www.php.net[/a] Link to comment https://forums.phpfreaks.com/topic/11832-trim-a-string/#findComment-44836 Share on other sites More sharing options...
redarrow Posted June 13, 2006 Share Posted June 13, 2006 [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] Link to comment https://forums.phpfreaks.com/topic/11832-trim-a-string/#findComment-44851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.