当前位置: 首页>>代码示例>>PHP>>正文


PHP array_sort_recursive函数代码示例

本文整理汇总了PHP中array_sort_recursive函数的典型用法代码示例。如果您正苦于以下问题:PHP array_sort_recursive函数的具体用法?PHP array_sort_recursive怎么用?PHP array_sort_recursive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_sort_recursive函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareSessionWithUniquePairs

 public function prepareSessionWithUniquePairs()
 {
     // lege array
     $array = [];
     // tel aantal users
     $count = $this->users->count();
     // geef elke user een andere user voor combo
     foreach (range(1, $count) as $value1) {
         foreach (range(1, $count) as $value2) {
             $pair = [$value1, $value2];
             // zolang users niet aan elkaar gelijk zijn en wanneer ook decombinatie omgedraaid niet wordt teruggevonden in de array van arrays
             if ($value1 != $value2 && !str_contains(json_encode($array), json_encode(array_sort_recursive($pair)))) {
                 $array[] = $pair;
             }
         }
     }
     // shuffle cards pls
     shuffle($array);
     // maak beginnende key een 1 ipv 0
     $array = array_filter(array_merge(array(0), $array));
     //steek ze in de sessie
     //$this->request->session()->put( 'combos' , $array );
     Cache::forever('combos', $array);
     return true;
 }
开发者ID:jonasvanderhaegen,项目名称:hotornot-app,代码行数:25,代码来源:Repository.php

示例2: allBranchByDate

 /**
  * all braches by date //dailysales/all
  */
 public function allBranchByDate(Carbon $date)
 {
     $ads = [];
     // array of dailysales
     //$bb = Branch::orderBy('code', 'ASC')->get();
     $bb = $this->branch->all(['code', 'descriptor', 'mancost', 'id']);
     //return $bb = $this->branch->getByCriteria(new ActiveBranch)->all(['code', 'descriptor', 'mancost', 'id']);
     foreach ($bb as $b) {
         // each bossbranch
         $ds = DailySales::whereBranchid($b->id)->where('date', $date->format('Y-m-d'))->first();
         if (is_null($ds)) {
             $ads[$b->code]['ds'] = NULL;
         }
         $ads[$b->code]['ds'] = $ds;
         $ads[$b->code]['br'] = $b;
     }
     return array_sort_recursive($ads);
     return array_sort($ads, function ($value) {
         return $value;
     });
 }
开发者ID:jrsalunga,项目名称:gi-boss,代码行数:24,代码来源:DailySalesRepository.php

示例3: seeJsonContains

 /**
  * Assert that the response contains the given JSON.
  *
  * @param  array  $data
  * @param  bool  $negate
  * @return $this
  */
 protected function seeJsonContains(array $data, $negate = false)
 {
     $method = $negate ? 'assertFalse' : 'assertTrue';
     $actual = json_encode(array_sort_recursive(json_decode($this->response->getContent(), true)));
     foreach (array_sort_recursive($data) as $key => $value) {
         $expected = $this->formatToExpectedJson($key, $value);
         $this->{$method}(Str::contains($actual, $expected), ($negate ? 'Found unexpected' : 'Unable to find') . " JSON fragment [{$expected}] within [{$actual}].");
     }
     return $this;
 }
开发者ID:ncusoho,项目名称:framework,代码行数:17,代码来源:CrawlerTrait.php

示例4: array_sort_recursive

 /**
  * Recursively sort an array by keys and values.
  *
  * @param  array  $array
  * @return array
  */
 function array_sort_recursive($array)
 {
     foreach ($array as &$value) {
         if (is_array($value) && isset($value[0])) {
             sort($value);
         } elseif (is_array($value)) {
             array_sort_recursive($value);
         }
     }
     ksort($array);
     return $array;
 }
开发者ID:PrafullaKumarSahu,项目名称:wordpress-socializr,代码行数:18,代码来源:helpers.php

示例5: seeJsonContains

 /**
  * Assert that the response contains the given JSON.
  *
  * @param  array  $data
  * @return $this
  */
 protected function seeJsonContains(array $data)
 {
     $actual = json_encode(array_sort_recursive(json_decode($this->response->getContent(), true)));
     foreach (array_sort_recursive(json_decode(json_encode($data), true)) as $key => $value) {
         $expected = $this->formatToExpectedJson($key, $value);
         $this->assertTrue(str_contains($actual, $this->formatToExpectedJson($key, $value)), "Unable to find JSON fragment [{$expected}] within [{$actual}].");
     }
     return $this;
 }
开发者ID:Calky,项目名称:uas,代码行数:15,代码来源:CrawlerTrait.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(PostRequest $request, $id)
 {
     $post = Auth::user()->posts()->find($id);
     if ($request->hasFile('images')) {
         $i = 0;
         $introImage = null;
         $images = unserialize($post->images) ? unserialize($post->images) : [];
         foreach ($request->file('images') as $key => $image) {
             if (isset($image)) {
                 $imageName = $key . '-image-' . str_random(10) . '.' . $image->getClientOriginalExtension();
                 if (!file_exists('img/posts/' . $post->user_id)) {
                     Storage::makeDirectory('img/posts/' . $post->user_id);
                 }
                 if ($key == 0) {
                     if ($post->image != NULL and file_exists('img/posts/' . $post->user_id . '/' . $post->image)) {
                         Storage::delete('img/posts/' . $post->user_id . '/' . $post->image);
                     }
                     $mainFile = Image::canvas(300, 200, '#ffffff');
                     $introFile = Image::make($image);
                     $this->file = $introFile;
                     $this->optimalResize(300, 200);
                     $mainFile->insert($this->file, 'center');
                     $mainFile->rectangle(0, 0, 299, 199, function ($draw) {
                         $draw->border(1, '#dddddd');
                     });
                     $mainFile->save('img/posts/' . $post->user_id . '/main-' . $imageName);
                     $introImage = 'main-' . $imageName;
                 }
                 // Creating images
                 $moreFile = Image::canvas(634, 432, '#ffffff');
                 $file = Image::make($image);
                 $this->file = $file;
                 $this->optimalResize(634, 432);
                 $moreFile->insert($this->file, 'center');
                 $moreFile->insert('img/watermark-blue.png', 'bottom-left', 10, 10);
                 $moreFile->rectangle(0, 0, 633, 431, function ($draw) {
                     $draw->border(1, '#dddddd');
                 });
                 $moreFile->save('img/posts/' . $post->user_id . '/' . $imageName);
                 // Creating mini images
                 $miniFile = Image::canvas(95, 71, '#ffffff');
                 $this->file = $file;
                 $this->optimalResize(95, 71);
                 $miniFile->insert($this->file, 'center');
                 $miniFile->rectangle(0, 0, 94, 70, function ($draw) {
                     $draw->border(1, '#dddddd');
                 });
                 $miniFile->save('img/posts/' . $post->user_id . '/mini-' . $imageName);
                 if (isset($images[$key])) {
                     Storage::delete(['img/posts/' . $post->user_id . '/' . $images[$key]['image'], 'img/posts/' . $post->user_id . '/' . $images[$key]['mini_image']]);
                     $images[$key]['image'] = $imageName;
                     $images[$key]['mini_image'] = 'mini-' . $imageName;
                 } else {
                     $images[$key]['image'] = $imageName;
                     $images[$key]['mini_image'] = 'mini-' . $imageName;
                 }
             }
         }
         $images = array_sort_recursive($images);
         $images = serialize($images);
     }
     $post->city_id = $request->city_id;
     $post->category_id = $request->category_id;
     $post->slug = str_slug($request->title);
     $post->title = $request->title;
     $post->price = $request->price;
     $post->deal = $request->deal;
     $post->description = $request->description;
     if (isset($introImage)) {
         $post->image = $introImage;
     }
     if (isset($images)) {
         $post->images = $images;
     }
     $post->address = $request->address;
     $contacts = ['phone' => $request->phone, 'telegram' => $request->telegram, 'whatsapp' => $request->whatsapp, 'viber' => $request->viber, 'phone2' => $request->phone2, 'telegram2' => $request->telegram2, 'whatsapp2' => $request->whatsapp2, 'viber2' => $request->viber2];
     $post->phone = json_encode($contacts);
     $post->email = $request->email;
     $post->comment = $request->comment;
     if ($tags_id = $request->input('tags_id')) {
         $post->detachTags();
         $post->attachTags($tags_id);
     }
     $post->save();
     return redirect('my_posts')->with('status', 'Объявление добавлено!');
 }
开发者ID:vizovteam,项目名称:vizov,代码行数:92,代码来源:PostsController.php

示例7: seeJsonContains

 /**
  * Assert that the response contains the given JSON.
  *
  * @param  array  $data
  * @param  bool  $negate
  * @return $this
  */
 protected function seeJsonContains(array $data, $negate = false)
 {
     $method = $negate ? 'assertFalse' : 'assertTrue';
     $actual = json_decode($this->response->getContent(), true);
     if (is_null($actual) || $actual === false) {
         return $this->fail('Invalid JSON was returned from the route. Perhaps an exception was thrown?');
     }
     $actual = json_encode(array_sort_recursive((array) $actual));
     foreach (array_sort_recursive($data) as $key => $value) {
         $expected = $this->formatToExpectedJson($key, $value);
         $this->{$method}(Str::contains($actual, $expected), ($negate ? 'Found unexpected' : 'Unable to find') . " JSON fragment [{$expected}] within [{$actual}].");
     }
     return $this;
 }
开发者ID:laravel,项目名称:lumen-framework,代码行数:21,代码来源:MakesHttpRequests.php

示例8: seeJsonEqualsExt

 /**
  * Assert that the response contains an exact JSON array.
  *
  * @param  array $data
  * @return $this
  */
 public function seeJsonEqualsExt(array $data)
 {
     $actual = json_encode(array_sort_recursive(json_decode($this->response->getContent(), true)), JSON_FORCE_OBJECT);
     $this->assertEquals(json_encode(array_sort_recursive($data), JSON_FORCE_OBJECT), $actual);
     return $this;
 }
开发者ID:TakahikoYoshii,项目名称:laravel,代码行数:12,代码来源:ExtTestMethodTrait.php


注:本文中的array_sort_recursive函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。