Tuesday, March 8

Php : Breaking a Long string using wordwrap function

While working on facebook application, the user email id can be a proxy id provided by facebook. This email id is a long piece of string. While displaying this email id, it would occupy most of the width on the page. I had to break the string using the php built in wordwrap function.

Consider this string.
$string = "apps.232434343432+4343245342.12323skj23236512312323216+343@proxy.facebook.com";
To break the string so that it fits inside a td tag of width 300px use the wordwrap() function

$new_string = wordwrap($string,40,'<br />',true);
Check out the php manual here

Be the first one to Comment!!!

Post a Comment