Answer the question
In order to leave comments, you need to log in
How to replace a piece of a string with another piece?
Actually the problem is to replace the city identifier (number) in api vk with a normal name.
There is a line like:
"name": Vasya
"birthday": 1/1/1990
"city": 1
And a line like this:
"name": Moscow
So, I need to swap "1" and "Moscow" and output one normal line, to make it clear what kind of city.
Answer the question
In order to leave comments, you need to log in
$cities = json_decode($citiesVk, true);
$citiesNamesMap = array_column($cities, 'name', 'id');
$user = json_decode($vkUser, true);
$user['city'] = $citiesNamesMap($user['city']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question