Jump to content

Easy ? Display Array values


ThalieMTL

Recommended Posts

Hi, 

It's my first time here. I'm not a coder but I sometimes need to find solutions by myself so here I am...

I think this one will be easy for all of you.

I generate a PDF displaying data from fields on a DB

They all display very well except the multiple choices.

Here is an exerpt of my code; I tried the implode code to display my values separated by commas but in the document it stil displays "Array" (screenshot enclosed) instead of something like: "Sante mentale, Reussite scolaire, Environnement sain "

And I obviously don't know what's wrong...

<tr><td><?php echo $fields['prenomact']['value']; ?> <?php echo $fields['nomact']['value']; ?></td><td><?php echo $fields['titreact']['value']; ?></td></tr>
<tr><td><?php echo $fields['courrielact']['value']; ?></td><td><?php echo $fields['telact']['value']; ?></td></tr>
<tr><td>Enjeux visés: <?php $fields['enjeux']=implode(",", $array); echo $fields['enjeux']['value'];?></td><td>territoire: <?php echo $fields['territoire']['value']; ?></td></tr>
<tr><td>Participation des enfants: <?php echo $fields['niveauparticipation']['value']; ?></td><td>Nombre d'enfants participants : <?php echo $fields['nbenfants']['value']; ?></td></tr>

Thanks in advance for your help,

Valérie

 

Capture d’écran 2018-12-02 à 12.25.15.png

Link to comment
Share on other sites

Thanks for your quick response benanamen !

Hum... OK but the data is collected and stored by a WP plugin named Ninja Forms.

Their basic pdf was only  saying:

<html><head>
    <link type="text/css" href="<?php echo $css_path; ?>" rel="stylesheet" />
</head><body>
    <h1><?php echo $title; ?></h1>
    <?php echo $table; ?>
</body></html>

And the fields were very well displayed, separated by commas... I needed to customize the PDF so I recreated it field by field.

Link to comment
Share on other sites

You get "Array" output when you attempt to echo an array variable.

$myArr = [1,2,3];
echo $myArr;          //--> Array

I have no idea what your data structure is, but it looks like $fields['niveauparticipation']['value']  is an array.

[EDIT]Try this to check

echo '<pre>', print_r($fields, 1), '</pre>';

 

Edited by Barand
Link to comment
Share on other sites

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.