Example #1
0
        private static string print_r(PHPArray dic, int depth)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Array");
            sb.AppendLine(print_r_tag(depth) + "(");
            if (dic != null)
            {
                foreach (KeyValuePair <object, object> entry in dic)
                {
                    object key = entry.Key;
                    object val = entry.Value;
                    if (val is PHPArray)
                    {
                        sb.Append(print_r_tag(depth + 1));
                        sb.Append("[");
                        sb.Append(key);
                        sb.Append("] => ");
                        sb.AppendLine(print_r(val as PHPArray, depth + 2));
                    }
                    else
                    {
                        sb.Append(print_r_tag(depth + 1));
                        sb.Append("[");
                        sb.Append(key);
                        sb.Append("] => ");
                        sb.AppendLine(val.ToString());
                    }
                }
            }
            sb.Append(print_r_tag(depth) + ")");
            return(sb.ToString());
        }
Example #2
0
        public static string print_r(PHPArray dic, bool @return)
        {
            string str = print_r(dic, 0);

            if (!@return)
            {
                Console.WriteLine(str);
            }
            return(str);
        }
Example #3
0
        public static PHPArray array(params object[] objs)
        {
            PHPArray ary = new PHPArray();

            foreach (object obj in objs)
            {
                ary.Add(obj);
            }
            return(ary);
        }
Example #4
0
        public static PHPArray array(string[] keys, object[] objs)
        {
            if (keys.Length != objs.Length)
            {
                throw new ArgumentException("数组数量不一样");
            }
            PHPArray ary = new PHPArray();

            for (int i = 0; i < keys.Length; i++)
            {
                ary.Add(keys[i], objs[i]);
            }
            return(ary);
        }
Example #5
0
 public static void print_r(PHPArray dic)
 {
     print_r(dic, false);
 }