combine() публичный статический Метод

Example: $keys = array('id', 'name', 'surname'); $values = array(1, 'john', 'smith'); $combined = Arrays::combine($keys, $values); Result: Array ( [id] => 1 [name] => john [surname] => smith )
public static combine ( array $keys, array $values ) : array
$keys array
$values array
Результат array
Пример #1
0
 public static function __callStatic($name, $arguments)
 {
     Session::checkSession();
     $dynamicFinder = DynamicFinder::match($name);
     if ($dynamicFinder) {
         $where = Arrays::combine($dynamicFinder->getNames(), $arguments);
         return static::where($where);
     }
     throw new BadMethodCallException('Method [' . $name . '] not exists');
 }
Пример #2
0
 public function setParameters($uri)
 {
     $ruleUri = explode('/', $this->getUri());
     $requestUri = explode('/', $uri);
     $filterParameters = FluentArray::from($ruleUri)->filter(function ($parameter) {
         return preg_match('#:\\w+#', $parameter);
     })->map(function ($parameter) {
         return str_replace(':', '', $parameter);
     })->toArray();
     $filterValues = array_intersect_key($requestUri, $filterParameters);
     $this->parameters = Arrays::combine($filterParameters, $filterValues);
 }
Пример #3
0
 /**
  * @test
  */
 public function shouldReturnCombinedArray()
 {
     //given
     $keys = array('id', 'name', 'surname');
     $values = array(1, 'john', 'smith');
     //when
     $combined = Arrays::combine($keys, $values);
     //then
     Assert::thatArray($combined)->hasSize(3)->containsKeyAndValue(array('id' => 1, 'name' => 'john', 'surname' => 'smith'));
 }