I would like to do a file dependency like Wordpress, But I cannot seem to get it right. I am trying to sort the array below so that all dependences are above of the array that depends on it. The dependency array might have just one entry or may have multiple entries ( [jquery] or [jquery,bootstrap])
This question has been answered by a nice man here
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
)
)
)
This array is just an example, the real array will have a lot more items within it and all will be in a random order.
Thanks in advance.