Syntax problem for $x

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
If the variable $delt1 is 8 I want the output

<td class="vt8" >

Which will have read the value of $delt1 from

<td class="vt<?= $delt1 ?>">

As this is part of a larger code I am trying to use x for the number in  

<td class="vt<?= $delt.$x ?>">
does not work.

Any help greatly appreciated.

Garry Jones

Re: Syntax problem for $x

Garry Jones wrote:
Quoted text here. Click to load it

Try this:

<td class="vt<?php
  $var = "delt$x";
  echo $$var;

An even better solution would be to have an array called $delt and
store all data that are now the $delt* variables as array's elements.
This way, you could simply do:

<td class="vt<?= $delt[$x] ?>">


Re: Syntax problem for $x

I prefer the following method.

echo '<td class="vt' . $delt . $x . '">';

Site Timeline