我想像Wordpress一样做一个文件依赖,但我似乎无法做到正确。我试图对下面的数组进行排序,以便所有依赖都高于依赖于它的数组。依赖项数组可能只有一个条目,也可能有多个条目([jquery]或[jquery,bootstrap])
这个问题已由一位好人回答
Sort array dependent of another array keys values
Array
(
[0] => Array
(
[name] => jquery
[version] => 1.1
[file] => vendor/jquery/jquery.js
)
[1] => Array
(
[name] => cookie
[version] => 1.0
[file] => vendor/cookie/cookie.js
[dependency] => Array
(
[0] => jquery
)
)
[2] => Array
(
[name] => admin
[version] => 1.0
[file] => vendor/admin/code.js
[dependency] => Array
(
[0] => jquery
[1] => bootstrap
[2] => checkbox
[3] => cookie
)
)
[3] => Array
(
[name] => bootstrap
[version] => 1.0
[file] => vendor/bootstrap/js/bootstrap.js
[dependency] => Array
(
[0] => jquery
)
)
[4] => Array
(
[name] => checkbox
[version] => 1.0
[file] => vendor/checkbox/checkbox.js
[dependency] => Array
(
[0] => jquery
[1] => bootstrap
)
)
)
这个数组只是一个例子,真正的数组中将包含更多的项目,并且所有项目都是随机顺序。
提前致谢。