Location: PHPKode > projects > DOCXGEN > djpate-docxgen-c0e9a71/example.php
<?php

require("phpDocx.php");

$phpdocx = new phpdocx("template.docx");

//$phpdocx->addImage("dog1","./example_dog.jpg");


$phpdocx->assignToHeader("#HEADER1#","Header 1"); // basic field mapping to header
$phpdocx->assignToFooter("#FOOTER1#","Footer 1"); // basic field mapping to footer


$phpdocx->assign("#TITLE1#","Pet shop list"); // basic field mapping

$phpdocx->assignBlock("members",array(array("#NAME#"=>"John","#SURNAME#"=>"DOE"),array("#NAME#"=>"Jane","#SURNAME#"=>"DOE"))); // this would replicate two members block with the associated values

$phpdocx->assignNestedBlock("pets",array(array("#PETNAME#"=>"Rex")),array("members"=>1)); // would create a block pets for john doe with the name rex
$phpdocx->assignNestedBlock("pets",array(array("#PETNAME#"=>"Rox")),array("members"=>2)); // would create a block pets for jane doe with the name rox

$phpdocx->assignNestedBlock("toys",array(array("#TOYNAME#"=>"Ball"),array("#TOYNAME#"=>"Frisbee"),array("#TOYNAME#"=>"Box")),array("members"=>1,"pets"=>1)); // would create a block toy for rex
$phpdocx->assignNestedBlock("toys",array(array("#TOYNAME#"=>"Frisbee")),array("members"=>2,"pets"=>1)); // would create a block toy for rox

$phpdocx->save("pets.docx");
?>
Return current item: DOCXGEN