Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel tree category

 public function autocomplete(array $tree, $parent_id = 0, $parent_name = null)
    {
        $result = [];
        foreach ($tree as $item) {
            if (!empty($parent_name)) {
                $name = $parent_name . ' > ' . AdminService::trans($item['title']);
            } else {
                $name = AdminService::trans($item['title']);
            }
            $result[] = [
                'id' => $item['id'],
                'title' => $name,
            ];
            if (count($item['children']) > 0) {
                $result = array_merge($result, $this->autocomplete($item['children'], $parent_id, $name));
            }
        }
        return $result;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: Disable wordpress editor - gutenberg on Post type post 
Php :: store fetched data into array php 
Php :: if else if ternary php 
Php :: wordpress php cpt get all taxonomy 
Php :: PHP utf8_encode — Converts a string from ISO-8859-1 to UTF-8 
Php :: Merge Two Collection or Array 
Php :: clear console php 
Php :: laravel query builder get data as array of array 
Php :: in laravel date duration validation rule 
Php :: how to store an image in laravel directly from url 
Php :: fresh migrqte laravel 
Php :: remove certain haracters from a string php 
Php :: mysqli fetch row assoc 
Php :: php array check 
Php :: Laravel: Validation unique on update 
Php :: string to decimal php 
Php :: php echo variable 
Php :: laravel wherein example 
Php :: remove string after comma in php 
Php :: how to remove keys in subarray php 
Php :: laravel without global scope 
Php :: install logger bundle in symfony project 
Php :: increase php memory 
Php :: laravel create new file if not exists 
Php :: Day of Week Using carbon library 
Php :: create controller with model resources and request command in laravel 
Php :: laravel eloquent relationships count 
Php :: Group by not working - Laravel 
Php :: error_log wordpress 
Php :: write php online 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =