https://streamerapi.finance.yahoo.com/streamer/1.0?s=AMD,ATACX,AUDUSD=X,BAC,BHI,CHK,CL=F,CSSBX,EDV,ENS,ES=F,EURUSD=X,FEGIX,FEGOX,GBPUSD=X,GC=F,GLPG,GOEX,JPY=X,LTPZ,M,MMYT,NQ=F,NVDA,NZDUSD=X,PAAS,PEGA,PL=F,PLNT,PRGO,RAI,SGGDX,SI=F,SILJ,SNAP,VGLT,XIV,XON,YM=F,ZG=F,ZI=F,^FTSE,^N225,^RUT,^TNX,^VIX&k=c64,p44,l86,t54,c63,p43,l84,t53&callback=parent.yfs_u1f&mktmcb=parent.yfs_mktmcb&gencallback=parent.yfs_gencb&mu=1&lang=en-US®ion=US&localize=0
$data = [
[
'name' => 'Москва и Московская обл.',
'items' => ['Москва', 'Абрамцево']
],
[
'name' => 'Санкт-Петербург',
'items' => ['Санкт-Петербург', 'Александровская']
]
];
class Location
{
private $data;
/**
* Location constructor.
*
* @param array $data
*/
function __construct($data = [])
{
$this->data = $data;
}
/**
* Get cities by region
*
* @param string $region
*
* @return array
*/
public function getCitiesByRegion($region)
{
$key = array_search($region, array_column($this->data, 'region'));
if ( $key === false ) return false;
return $this->data[$key]['items'];
}
}
$data = [
[
'region' => 'Москва и Московская обл.',
'items' => ['Москва', 'Абрамцево']
],
[
'region' => 'Санкт-Петербург',
'items' => ['Санкт-Петербург', 'Александровская']
]
];
$location = new Location($data);
print_r($location->getCitiesByRegion('Санкт-Петербург'));
function pad(num, size) {
var s = (num+1)+"";
while (s.length < size) s = "0" + s;
return s;
}
pad(004, 3);
pad(005, 3)