Replies: 1   Views: 118
What is the correct syntax inside an array?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 24-05-2022 - 10:55


Sorry, but we are not sure if we understand your question correctly.

In your code you are adding a new list with [$name, 'word'] in the second level and 'Example text.' in the first level.

If you use:

$myList = array(
    $name, 'word', 'Example text.',

all elements will be in the same level (first level in this case).

Please check the following sample available in all packages (Core/addList/sample_3.php) that illustrates a complex list applying styles using WordFragments:

// prepare some formatted text for insertion in the list
$textData = new WordFragment($docx);
$text = array();
$text[] = array('text' => 'We insert some ');
$text[] = array('text' => 'bold text', 'bold' => true);

// and also some simple HTML to illustrate the fexibility of the method
$htmlData = new WordFragment($docx);
$html = '<i>Some HTML code</i> with a <a href="">link</a>';

$itemList= array(
    'In this example we use a custom list (val = 5) that comes bundled with the default PHPdocX template.',
        'Line B',
        'Line C'
    'Line 3',

// set the style type to 5: other predefined Word list style
$docx->addList($itemList, 5);

If you send to contact[at] the DOCX output you get now and the DOCX output you want to get after updating the same DOCX manually using MS Word or any other DOCX program we'll check it.