0

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.

Community
  • 1
  • 1
  • The possible duplicate question only assumes that the sort array is a single value, not a multiple value like above. –  Jun 20 '16 at 09:23
  • Can someone explain why this is a duplicate question, please point me to the answer on the other posts thank you. –  Jun 20 '16 at 12:17
  • Please can someone show me an example how to do this, I have looked at the other posts but they don't help me, I have been at this for 5 days now. Please Please can someone show me an example, thank you –  Jun 20 '16 at 15:51

0 Answers0