检查表记录存在(删除前检查)

1.示例: $arr = ['table1'=>'list1|list2', 'table2'=>'list1|list2']

@param $array, $val

@return boolean
960656
public function exsitsIn($array, $val)
	{
		foreach ($array as $key => $value) {
			$keys =  explode('|', $value);
			foreach ($keys as $k) {
				$recs = DB::table($key)->where($k, $val)->get();
				if(count($recs)) return true;
			}	
		}

		return false;
	}
1367712
private function validateArray(array $array): bool
  {
    foreach ($array as $element)
    {
      if (is_array($element))
      {
        $tmp = $this->validateArray($element);
        if ($tmp===true)
        {
          return true;
        }
      }
      else
      {
        if ($element!==null && $element!==false && $element!=='')
        {
          return true;
        }
      }
    }

    return false;
  }
1229320
function insert(array $arr) {
        if (empty($arr)) return false;
        $comma = '';
        $fileds = '';
        $prepare='';
        foreach ($arr as $key => $value) {
            $params[] = $value;
            $fileds .= "$comma `$key`";
            $prepare .= "$comma ?";
            $comma = ',';
        }

        $sql = "INSERT INTO  `$this->table`({$fileds}) VALUES({$prepare})";
        $this->execute($sql, $params);
        return $this->db->lastInsertId($this->id);
        /*
         * 此方式不支持sqlite,舍弃
        if (empty($arr)) return false;
        $comma = '';
        $setFields = '';
        foreach ($arr as $key => $value) {
            if (is_array($value)) {
                $setFields .= "{$comma} `{$key}`=" . current($value);
            }
            else {
                $params[] = $value;
                $setFields .= "$comma `$key`=?";
            }
            $comma = ',';
        }

        $sql = "INSERT INTO  `$this->table` set {$setFields}";
        $sql = str_replace('table.',$this->table.'.',$sql);
        $this->db->sql($sql, $params);
        return $this->db->lastInsertId($this->id);
        */
    }
1281462
public static function ksortRecursive(&$array)
    {
        if (!is_array($array)) {
            return false;
        }

        ksort($array);
        foreach ($array as $key => $value) {
            static::ksortRecursive($array[$key]);
        }

        return true;
    }
1162044
public static function isAssociativeArray($array)
    {
        if (is_array($array)) {
            foreach (array_keys($array) as $k => $v) {
                if ($k !== $v) {
                    return true;
                }
            }
        }

        return false;
    }
1133027
protected static function isArrayMultiline($array)
    {
        if (empty($array)) return false;

        switch (self::getArrayMode()) {
            case self::ARR_MODE_SINGLELINE:
                $isMultiline = false;
                break;
            case self::ARR_MODE_MULTILINE:
                $isMultiline = true;
                break;
            default: // for ARR_MODE_AUTO
                $isMultiline = Arr::isAssoc($array) ? true : false;
                return $isMultiline;
        }
        return $isMultiline;
    }
254063
public function matchesPackage(array $array) {
		if (isset($array['package']) && $array['package'] == $this->package->getName()
				&& isset($array['class']) && $array['class'] == $this->getClassName()) {
			return true;
		} else {
			return false;
		}
	}
197087
public static function isList($val): bool
    {
        if (!\is_array($val) || !isset($val[0])) {
            return false;
        }

        /** @var array $val */
        $keys = \array_keys($val);

        return \array_keys($keys) === $keys;
    }
347189
public static function array_unshift_assoc(&$arr, $key, $val)
    {
        $arr = array_reverse($arr, true);
        $arr[$key] = $val;
        $arr = array_reverse($arr, true);
        return $arr;
    }
522978
public static function array_type(&$arr=null) {
		if (! \is_array($arr) || ! \count($arr)) {
			return false;
		}

		$keys = \array_keys($arr);
		if (\range(0, \count($keys) - 1) === $keys) {
			return 'sequential';
		}
		elseif (\count($keys) === \count(\array_filter($keys, 'is_numeric'))) {
			return 'indexed';
		}
		else {
			return 'associative';
		}
	}
1094269
private function checkKey(array $arr)
    {
        foreach ($arr as $key => $val) {
            // 下标只允许包含字母、数字、下划线
            if (preg_match("/[^a-z0-9_]/i", $key)) {
                throw new \Exception('“' . $key . '”配置下标只允许包含字母、数字、下划线');
            }
            
            if (is_array($val)) {
                $this->checkKey($val);
            }
        }
    }
1195970
protected function isSequentialArray(array $arr)
    {
        if (empty($arr)) {
            return true;
        }
        return (range(0, count($arr) - 1) === array_keys($arr));
    }
1057724
public static function getArrayDiffRecursively($array1, $array2)
    {
        $diff_array = [];

        // value 비교
        if (!is_array($array1)) {
            if ($array1 != $array2) {
                return $array1;
            } else {
                return [];
            }
        }

        // array 비교
        foreach ($array1 as $key => $value) {
            if (is_array($value)) {
                if (!is_array($array2[$key])) {
                    $diff_array[$key] = $value;
                } else {
                    $sub_diff_array = ArrayUtils::getArrayDiffRecursively($value, $array2[$key]);
                    if (count($sub_diff_array)) {
//                        $diff_array[$key] = $sub_diff_array;
                        $diff_array[$key] = $value;
                    }
                }
            } elseif ($array2[$key] != $value) {
                $diff_array[$key] = $value;
            }
        }
        return $diff_array;
    }
324699
public static function isIndexedArray($arr)
    {
        if (!is_array($arr)) {
            return false;
        }
        if (array_values($arr) === $arr) {
            return true;
        }
        return false;
    }
784433
function has (array, val) {
  var rtn = false;
  if (Array.isArray(array)) {
    rtn = !!~array.indexOf(val);
  }
  return rtn;
}
572316
public static function IsSingleDepth( array $array ) : bool
   {

      if ( \count( $array ) < 1 )
      {
         return false;
      }

      foreach ( $array as $v )
      {
         if ( \is_array( $v ) && \count( $v ) > 0 )
         {
            return false;
         }
      }

      return true;

   }
1252040
public static function isList(array $array): bool
	{
		$count = count($array);

		$range = $count
			? range(0, $count - 1)
			: [];

		$keys = array_keys($array);

		return $keys === $range;
	}