Jump to content

Recommended Posts

Use this function if you want to specify the length of the split: http://php.net/manual/en/function.substr.php

echo substr('abcdef', 1);     // bcdef
echo substr('abcdef', 1, 3);  // bcd
echo substr('abcdef', 0, 4);  // abcd
echo substr('abcdef', 0, ;  // abcdef
echo substr('abcdef', -1, 1); // f

 

Or use explode as you meantioned if you use a specific delimiter: http://php.net/manual/en/function.explode.php

$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2

Ok so I got it working based on the latest solution...

 

Basically I have a writable PDF that I am creating based on user generated information from the web. The PDF has a two part question and I am taking the user input from a textarea that I am then breaking apart and placing on the PDF in two separate parts.

 

But my dilemma is what if the last part of the first section contains a word that breaks in half (IE: description, between, because, etc.) and then the word continues on the second line. I am wondering if I could split the last word on the first line and place a dash in the word to let others reading it know that the word continues on the second line...

 

Make sense? Sorry if that is confusing... its hard to place what I need help on to words lol

 

I don't think those have anything to do with what the OP is asking for now. I believe the OP is now asking how to logically break a word at a syllable, i.e. hyphenate it. Example (lines 1 & 3):

Toyota has for years blocked access to data stored in de-
vices similar to airline "black boxes" that could explain
crashes blamed on sudden unintended acceleration, accord-
ing to an Associated Press review of lawsuits nationwide
and interviews with auto crash experts.

 

@OP: If you are creating the PDF file via the PHP PostScript functions there are a couple that may help: ps_show_boxed() and/or ps_hyphenate().

 

however, if you are creating the PDF through other means, e.g. writing raw postscript and distilling this may be more difficult as you will not "know" ahead of time where the word will need to break.

 

@Dennis1986, I like how you updated your original post to include information about using substr() after I posted a solution using it. :)

@Dennis1986, I like how you updated your original post to include information about using substr() after I posted a solution using it. :)

 

What are you talking about?

I modified my post because the editor added in some bbcode that shouldn't be there.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.