2017 © Pedro Peláez
 

library fast-cache

a php fast cache library

image

phpding/fast-cache

a php fast cache library

  • Wednesday, December 20, 2017
  • by phpding
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

//js树形查找, (*1)

function getName(arr, id) {, (*2)

    var num = arr.length;

    for (var i = 0; i < num; i++) {
        if (arr[i].id == id) {
            return arr[i].name
        } else {
            if (arr[i].children) {
                var name = getName(arr[i].children, id)
                if(name){
                    return name;
                }
            }
        }
    }
    return ''
}

var trees = [
    {
        id: 1,
        name: 'a',
        children: [
            {
                id: 4,
                name: 'b'
            },
            {
                id: 5,
                name: 'd'
            }

        ]
    },
    {
        id: 6,
        name: 'aa',
        children: [
            {
                id: 7,
                name: 'bb'
            },
            {
                id: 8,
                name: 'dd'
            }

        ]
    },
    {
        id: 2,
        name: 'b',
        children: []
    },
    {
        id: 3,
        name: 'd',
        children: []
    }
]

console.log(getName(trees, 8))

console.log(getName(trees, 5))

The Versions

20/12 2017

dev-master

9999999-dev https://github.com/phpding/fast-cache

a php fast cache library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache fast