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!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.