Ejemplo n.º 1
0
        public static PhpArray Scan(string directory, int sorting_order)
        {
            StreamWrapper wrapper;

            if (!PhpStream.ResolvePath(ref directory, out wrapper, CheckAccessMode.Directory, CheckAccessOptions.Empty))
            {
                return(null);
            }

            string[] listing = wrapper.Listing(directory, 0, null);

            if (listing != null)
            {
                PhpArray ret = new PhpArray(listing);                 // create the array from the system one
                if (sorting_order == 1)
                {
                    PhpArrays.ReverseSort(ret, ComparisonMethod.String);
                }
                else
                {
                    PhpArrays.Sort(ret, ComparisonMethod.String);
                }
                return(ret);
            }
            return(null);            // false
        }
Ejemplo n.º 2
0
        public void TestRandomKeys()
        {
            PhpArray a = PhpArray.Keyed("Server1", 1, "Server2", 2, "Server3", 3);

            PhpVariable.Dump(a);
            string result = PhpArrays.RandomKeys(a) as string;

            Assert.IsTrue(result == "Server1" || result == "Server2" || result == "Server3");
        }