Replies: 2   Views: 3807
Array to string error in tutorial
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 kshaikh  · 24-07-2013 - 06:41


I was trying to run the following code from tutorial:

require_once '../phpdocx_community/classes/';

$docx = new CreateDocx();
$text = array();
$text[] =
'text' => 'I am going to write'
$text[] =
'text' => ' Hello World!',
'b' => 'on'

$text[] =
'text' => ' using bold characters.'

and ran into the following error:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:\xampp\htdocs\phpdocx_community\classes\ on line 576

It looks like the function addText is unable to use $text as an input argument since it is an array. Did anyone run into this issue? I tried to convert the array into a string by using implode method but it didn't print the value as expected. Instead, it simply printed "ArrayArrayArray".

Please advise.