dennismonsewicz Posted April 27, 2010 Share Posted April 27, 2010 I have a function that takes a string and splits it up into two parts... well I keep running into the issue of Uninitialized String Offest: 52... but it only happens when the string is more than the specified length.. function string_into_parts($text, $length=45) { $text = trim($text); $array = array(); if(strlen($text) > $length) { for($i=0;$text[$length+$i]!=" ";$i++) { if(!$text[$length+$i]) { return $text; } } $array['firstHalf'] = trim(substr($text,0,$length+$i)); $array['secondHalf'] = trim(substr($text,$length+$i)); } else { $array['firstHalf'] = $text; $array['secondHalf'] = ''; } return $array; } Any help is much appreciated!!!! Link to comment https://forums.phpfreaks.com/topic/199876-uninitialized-string-offset-52/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.