kvnmck18 Posted May 4, 2008 Share Posted May 4, 2008 I'm trying to get a string (I just put some numbers as a test -- there are 134 total chars in "$GetDescript") - and count the total number of characters in the string. If the string is over 130 chars then only the first 130 chars can be stored in the Description1, and the "overflow" or remaining characters are in the $Description2.This is my start: $GetDescript = ".0.2.4.6.8.13.0.2.4.6.8.26.0.2.4.6.8.39.0.2.4.6.8.52.0.2.4.6.8.65.0.2.4.6.8.78.0.2.4.6.8.91.0.2.4.6.8.105.0.2.4.6.8.119.0.2.4.6.8.133."; $CountDescChars = strlen($GetDescript); if ($CountDescChars >= 130) { $Description1 = (only the first 130 characters here); $Description2 = (the remaining 4 chars should be here); } else { $Description1 = $GetDescript; } Link to comment Share on other sites More sharing options...
Wander Posted May 4, 2008 Share Posted May 4, 2008 you can just use the str_split function $GetDescript = ".0.2.4.6.8.13.0.2.4.6.8.26.0.2.4.6.8.39.0.2.4.6.8.52.0.2.4.6.8.65.0.2.4.6.8.78.0.2.4.6.8.91.0.2.4.6.8.105.0.2.4.6.8.119.0.2.4.6.8.133."; $Description = str_split($getDescript,130); it will return an array, with in each element maximum 130 characters Link to comment Share on other sites More sharing options...
zppblood Posted May 4, 2008 Share Posted May 4, 2008 $Description1 = substr($GetDescript, 0, 130); $Description2 =substr($GetDescript, 130); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.