-3
It is possible to use html tags within php variable. For example I am making a loop where I have a parent item that I want to take <strong>
and the children items I just add a -
, only if I do it at the time of setting the variable of the parent item $varPai = "<strong>{$varValue}"</strong>
, it does not render me the item with Strong, it is possible to do this within php?
this is my foreach that’s riding, father > sons
foreach($listaLocalidade as $p_id => $p_nome){
$cidades = $this->Localidade->find('list',array('conditions'=>"Localidade.Localidade_id ={$p_id}", 'Localidade.programas is not null'));
$opcoesPaisCidade[$p_id] = "<strong>{$p_nome}</strong>"; // aqui é o pai, onde eu teria que deixar strong
foreach($cidades as $c_id => $c_nome){
$opcoesPaisCidade[$c_id] = ' - '.$c_nome;
//die(print_r($opcoesPaisCidade));
}
}
And I’m riding like this:
<select id="combobox" name="data[orcamento][localidade_id]">
<option value="">Select one...</option>
<?php
foreach($opcoesPaisCidade as $p_id => $p_nome){
?>
<option value="<?=$p_id?>"><?=$p_nome?></option>
<?}?>
</select>
Yes, it is possible. Just put it in quotes, treating it as a string. In the case of the tag
strong
, it wouldn’t be better to use css to style no?– user28595
then in case, the way I did is right?
– Michel Henriq
Only now have I understood what you really intended, styling part of an option is out of the question. You just can’t.
– Edilson