 <p>If I may suggest an alternative approach - which is to use an array. You shouldn't try to dynamically create variable names. For that purpose, good engineers from a long, long time ago in a year far far away invented an array.</p> <p>So, to solve your problems from now and the whole eternity - rewrite your code to use:</p> <pre><code>$newNode-&gt;field[$key]['und'][0]['value'] = $value; </code></pre>