I almost have this working but am missing something. I have a string that I need to split into at most 2 smaller strings. It has to be split cleanly (not in the middle of text), and the first string cannot be longer than 25 characters. So for example, the following:
$mystring = "This Is My Manufacturer Name That Can Be Long"
Should be stored into 2 smaller strings like:
$mystring1 = "This Is My Manufacturer"
$mystring2 = "Name That Can Be Long"
I was going to use wordwrap() but that won't work because I need the values to be stored in 2 separate string variables. Is using explode() the way to go?
Btw, this is what I have. Is this the best way to do it?
$mfg_name_length = strlen($manu->name);
if ($mfg_name_length >= 25) {
$mfg_name_array = explode(" ", $manu->name);
$space_loc = strrpos(substr($manu->name, 0, 25), " ");
$pdf->addText(45,675,14,"Manufacturer: ".substr($manu->name, 0, $space_loc));
$pdf->addText(45,660,14,"Manufacturer: ".substr($manu->name, $space_loc+1, $mfg_name_length));