2
I have this tie that lists all the lines of array, but I only need a few lines. How to pass each result to a variable?
$WS->key='00000000000'; // Atenção: Este parâmetro possui valores diferentes
// Chamada do método e retorno da resposta.
$response=$WS->getInfo($param); // Esta função da classe WS_API retorna um objeto
$control_sign=array();
$control_sign=$WS->getResponse('getInfo',$response);
foreach ($response as $name => $value) {
echo $name .''. $value;
}
// Resultado
// shopId 33015842
// paymentMethod E_COMMERCE
// contractNumber 1026194250
// Nome Fabio
// Código com as Sugestões do Amigos
foreach ($response as $name => $value) {
echo $linha = "{$name}{$value}";
echo"<br>";
}
extract($response);
echo $amount;
I want to return only the lines shopId and paymentMethod.
OK almost that.... but I need to house line, move to a variable to be able to manipulate each one.
– Fabio Henrique
@Fabiohenrique Ali where the
echo ..
you can use a variable and concatenate the key and value like this:$linha = "{$chave}{$valor}";
, then just use the variablelinha
.– stderr
Hello Friend excuse the ignorance but I’m new to it hasn’t worked for being in a loop I can’t declare the variables I changed the initial code showing as this my original array
– Fabio Henrique
What I need is something like $var1 = $line . " <br>"; $var2 = $line . " <br>";... or $var1 = $line["os"];
– Fabio Henrique
I would need variableness could be up to foreach
– Fabio Henrique
In this model the code would be very large because it must have more than 30 lines. I only need the values in case something like Extract($reply); would solve more ta not working
– Fabio Henrique
how I needed to http://pastebin.com/sJ1LLuHK
– Fabio Henrique
@Fabiohenrique I understand now. = ) See if this is it: http://ideone.com/5pDqGi
– stderr
That’s right this is the most idea gave error Cannot use Object of type stdClass as array in
– Fabio Henrique
@Fabiohenrique
$response
is a object right? try to do so:$shopId = $response->shopId;
,$paymentMethod = $response->paymentMethod;
, etc..– stderr
Perfect... I can’t even put my thanks here....
– Fabio Henrique