Foreach PHP

i have a list of records, but only print id of table

$cidades = CidadeFactory::listCidadeByQuery(null, null);
     	if (!is_null($cidades)) {
		
			foreach($cidades as $cidade) {
				echo $cidade."-";
				echo '<br>';
			}
	}

//===PRINT======//

2-
6-
2 record(s) retrieved.

//===PRINT======//

i need print the name property OF THE object $cidade
is $cidade->getName(); ?
can help?

tanks

Hi Hussan,

Thanks for your post. Yes, it’s “$cidade->getName();” as long as you have an attribute/column “Name”.

If there are any further inquiries, please do not hesitate to ask.

Best regards,
Lilian Wong

Tanks Lilian

work fine

best regards
h2

Hi Hussan,

You are welcome. If there is any questions in the future, please do not hesitate to contact me.

Best regards,
Lilian Wong