GET STR syntax

Asked

Viewed 47 times

-2

answer from the JSON:

      "tipoLogradouro": "AVENIDA",
      "logradouro": "DOIS",
      "numero": "185",

PHP to collect the answer

        $tipolograd= GetStr($data, 'tipoLogradouro":' '",');
        $lograd= GetStr($data, 'lograd":' '",');
        $num= GetStr($data, 'num":' '",');

I’m sure I’m making a mistake "'','"

Can anyone give me an example of what that code would look like, correctly? How can I correctly delimit the area I need to pick up on this case

    1. do not greet or thank in the publications: See What kind of behavior is expected from users? 2) Do not use the publications to make complaints, for this there is the site [META] where you can open to the community a discussion specific to the evaluation of your question.
    1. Your question seems to have some problems and your experience here in Stack Overflow may not be the best because of it. We want you to do well here and get what you want, but for that we need you to do your part. Here are some guidelines that will help you: Stack Overflow Survival Guide in English (short version).

1 answer

3


To take the body of a request with php you can use file_get_contents()

$corpo = file_get_contents('php://input');

if the JSON body is used json_decode():

$json = json_decode($corpo);

then you can access the JSON items as a php object

echo $json -> tipoLogradouro; // AVENIDA
echo $json -> logradouro;     // DOIS
echo $json -> numero;         // 185

Browser other questions tagged

You are not signed in. Login or sign up in order to post.