Jump to content

Character Count - Dividing Up Overflow of the Count


kvnmck18

Recommended Posts

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

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

Archived

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

×
×
  • Create New...