Search code examples
phpword

PHPWORD how can i use function addText without break


example:hello world

i want to display above in one paragraph without breakup

add Text("hello");    
add Image('image URL');    
add Text("hello");

in this way. there will be 3 breaks

which paragraph will influence the break?


Solution

  • PHPWord addTextRun method's description

    With a textrun you can add text and textbreaks within one paragraph.

    $textrun = $section->addTextRun();
    $textrun->addText("hello");
    $textrun->addImage('image URL');
    //if you want to seperate the text
    //$textrun->addTextBreak();
    $textrun->addText("hello");