4
I have the Result of a Webservice below, I’m doing a "foreachs" to read each level of the Class, but I think it should have a more elegant way to read and get the values of the object, follows the Result:
stdClass Object
(
    [Codigo] => 1-0-21
    [Descricao] => REGIONAL DDD21
    [DddArray] => stdClass Object
        (
            [string] => 21
        )
    [Valores] => stdClass Object
        (
            [Valor] => Array
                (
                    [0] => stdClass Object
                        (
                            [ValorFace] => 1000
                            [ValorBonus] => 0
                            [Produto] => RECARGA CELULAR
                        )
                    [1] => stdClass Object
                        (
                            [ValorFace] => 1500
                            [ValorBonus] => 0
                            [Produto] => RECARGA CELULAR
                        )
                    [2] => stdClass Object
                        (
                            [ValorFace] => 2000
                            [ValorBonus] => 0
                            [Produto] => RECARGA CELULAR
                        )
                )
        )
)
This text is the result of the function:
$res = $client->RetornaRegionaisPorOperadoraDdd($params);
The way I’m doing it is very "POG":
foreach ($res as $key => $value){
    foreach ($value as $keyopera => $valopera){
        print_r($valopera);
    }
}
						
There is nothing wrong with what you presented. Nor can I say that it is a Pog.. rsrs ..
– Daniel Omine
POG is Gambarra Oriented Programming.
Foreachit’s an elegant way.– Diego Souza
A Gambiarra can contain a foreach() normally and continue to be a gambiarra.
– durtto
Yes, the way he did it was Vida Loka.
– Diego Souza
This did not generate error? if you are iterating
$res,$keycould beCodigo, ai$valuewill not take an array.– Guilherme Lautert