V
V
Vitaly2017-03-26 09:20:55
PHP
Vitaly, 2017-03-26 09:20:55

Variable in php associative array key?

I am writing a bot for the VK community in php.
Faced a problem:
There is an associative array of the form: 'Question' => "Answer"
I need to find out the weather in the city that the user specifies.
I know the weather through openweathermap, the city is specified in a separate script.
I need the name of the city written by the user in the request to be substituted into the script: Weather <city>, and in response, the weather for the specified city was sent, and in the case of simply entering: Weather, an error was displayed.
How to implement it in php? Is it even possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramm, 2017-03-26
@vitcorp

Of course available. Parse the string
php.net/manual/ru/ref.strings.php
Processing arrays ( php.net/manual/ru/ref.array.php ) display the response to the user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question