0
$modelProfileURL = $site_url.'profile/model/2/'.$rs_model[$i]['iModelId'].'/'.replace_content($rs_model[$i]['vFirstName']).'_'.replace_content($rs_model[$i]['vLastName']);

I need to truncate the first and last name to a max. of 25 characters. But I can't find the correct way to edit the code listed above. For example instead of the name being (for example: Mark Walker Smith Lewis Junior), it would only be Mark Walker Smith Lewis J. This is needed for design purposes. Can anyone assist?

  • 3
    Possible duplicate of [Get first n characters of a string](https://stackoverflow.com/questions/3161816/get-first-n-characters-of-a-string) – random_user_name Sep 13 '17 at 02:48

1 Answers1

0

$modelProfileURL = $site_url.'profile/model/2/'.$rs_model[$i]['iModelId'].'/'.replace_content(substr($rs_model[$i]['vFirstName'],0,25)).'_'.replace_content(substr($rs_model[$i]['vLastName'],0,25));

kmoser
  • 8,780
  • 3
  • 24
  • 40
  • Thank you for your assistance. But this did not limit the number of characters in the name. – Phone Chatter Sep 13 '17 at 03:19
  • You must be doing something wrong because ``substr()`` will definitely limit the string length when used as I described. Can you give an example of the contents of ``$modelProfileURL`` after this line is executed? – kmoser Sep 14 '17 at 04:24