Skip to content

Data Structure

MadaoIsMyBrother edited this page Feb 14, 2018 · 4 revisions

ary::map(array $array, $method) Mapping keys to values by given method

Open file ary.php in folder ./ary

  • Synopsis:

    ary::map(your_array, your_method)
   ary::map($input_array, function($key,$value){
       return $value*3;
   }); //returns an array with every item multiplied by 3

Summary:   Function accepts an array& a method and returns an array containing mapped values.
Description:  Function put all keys and original values into the given method and sets the return values of the method as new values for the given array then returns the new array.
Note:  Function will output an error if the user does not give a valid method.


ary::filter(array $array, $method) Get elements that satisfy a given method from a given array.

Open file ary.php in folder ./build

  • Synopsis:

    ary::filter(your_array, your_method)
ary::filter(input_array, function($key,$value){
  return $value>3;
}); //returns an array with only items larger than 3

Summary: Function accepts an array and a method then return an array
Description: Function inputs all keys and values from the given array into the given method then puts all the elements make the method return true into a new array.
Note: Function will output an error if the given method is invalid.


ary::merge(array $array) Merge all subarrays into one array

Open ary.php in folder ./ary

  • Synopsis:

    ary::map(your_array, your_method)
ary::merge([1,2,3],[4,5,6]);
//returns [1,2,3,4,5,6]

ary::size(array $array) Get the size of the array

Open ary.php in folder ./ary

  • Synopsis:

    ary::size(your_array)
ary::size([1,2,3]);
//returns 3

ary::last(array $array) Get the value of the last element in array

Open ary.php in folder ./ary

  • Synopsis:

    ary::last(your_array)
ary::last([1=>1,2=>2,3=>3]);
//returns 3

ary::flat(array $array) Put all values in subarrays and values in the given array into one array.

Open ary.php in folder ./ary

  • Synopsis:

    ary::flat(your_array)
ary::flat([[1,2,3],[4,5,[6,7,8]]]);
//returns [1,2,3,4,5,6,7,8]

Summary: Accepts an array and returns an array.
Description: Put all the values in the given array and the values in the subarrays together into one array. Then the function returns the new array. Subarrays will not exists in the returned array.


is::mobile() Check the user's agent is a computer or a mobile phone.

open file is.php in folder ./is

  • Synopsis:

    is::mobile()
is::mobile()
//true if user is using a phone

Description: Function transform the user's agent string into lower letters then check if it contains 'mobile', 'android', or 'phone' to determine what agent the user is using.


is::empty($in_p=null) Check if anything is empty

open is.php in folder ./is

  • Synopsis:

    is::empty(your_array_file_or_str)
is::empty($array_file_or_str)
//true if []/['','']/''/0 or $_FILES['a_file'] does not exists

Summary: Function accepts an array or a string and returns a boolean.
Description: If the user inputs an array, function will check if $_FILES is empty, if array as whole is empty, and if any array item is empty. If the user inputs a string, function will check if the string is an empty string.
Note: Function returns false if $in_p is not an array or a string.


is::ary($input) Judge if the input is an array

Open is.php in folder ./is

  • Synopsis:

    is::ary(your_array)
is::ary($array);
//true if $array is an array

is::str($input) Judge if the input is a string

Open is.php in folder ./is

is::str($str);
//true if $str is a string

is::int($input) Judge if the input is an integer

Open is.php in folder ./is

is::int($int);
//true if $int is an integer

is::float($input) Judge if the input is a float

Open is.php in folder ./is

is::float($float);
//true if $float is a float

regex($input) check if the input matches a regular expression

opens is.php in folder ./is

is::regex($input);  
//true if $input is a regular expression

Summary: Function returns true if the input matches a regular expression and returns false if the input does not match a regular expression


is::in($part, $full) Check if $part is a part of $full

open file is.php in folder ./is

  • Synopsis:

    is::in(your_part,your_full)
is::in($part,$full); 
//true if $part is a part of $full

Summary: Function accepts two parameters and returns true if the first parameter is a part of the second parameter.
Description: If $full is an array, function will loops over $full and check if $part is a part of a value in the array. If $full is not an array and $part is a regular expression, function will check if $part and $full perform a regular expresssion match. If $full is not an array and $part is not a regular expression, function will assume they are strings and check if $part is a substring of $full.


is::url(string $url) check if any url is in the input string and return the url if ther are any.

open file is.php in folder ./is

is::url(string $url)
//true if any url is contained in $url

is::dir(string $url) check if the input string has an directory and return the directory if there are any.

open file is.php in folder ./is

is::dir(string $dir)
//true if any directory is contained in $dir

is::email(string $email) check if the input string has an email and return the email if there are any.

open file is.php in folder ./is

is::email(string $email)
//true if an email address is contained in $email

str::html(string $in_p) Input a string and tranfomr it to html format

open file str.php in folder ./str

  • Synopsis:

    str::html(your_string)
str::html('hello world'); //returns 'hello world'

Description: Function will check specific characters and change them to html characters to change the strng to html format. Then the function will return the html format string.


str::utf8(string $in_p) change the input string to html format and return the new string

open file str.php in folder ./str

  • Synopsis:

    str::utf8(your_html_string)
str::utf8('hello world'); //returns 'hello world'

str::cut(string $in_p, $limit) cut the given string and return the new string containing the first $limit characters

open file str.php in folder ./str

  • Synopsis:

    str::cut(your_string,your_length)
str::cut('hello world',7); //returns 'hello w'

str::lower($input) Change all strings in input to lower case

open file str.php in folder ./str

  • Synopsis:

    str::lower(your_string_or_your_array)
str::lower('Hello WorlD'); //returns 'hello world'  
str::lower(['H','COM']); //returns ['h','com']

Summary: Function accepts a string and returns that string in lower case or accepts an array of strings and returns that array of strings in lower case.


str::upper($input) Change all strings in input to lower case

open file str.php in folder ./str

  • Synopsis:

    str::upper(your_string_or_your_array)
str::upper('Hello WorlD'); //returns 'HELLO WORLD'  
str::lower(['h','com']); //returns ['H','COM']

Summary: Function accepts a string and returns that string in upper letters or accepts an array of strings and returns that array of strings in lower letters.


str::random($limit=10) return a $limit length randomly made string

open file str.php in folder ./str

  • Synopsis:

    str::random(your_length)
str::random(8); //generates an random str with the length of 8  

Summary: Function accepts a given length to make a string and returns a randomly made string.
Description: Function will randomly choose $limit numbers(The default value of limit is 10) from capital letters A-Z and lower case a-z. Then function returns string that has a length of $limit.


str::unix_dir(string $path) Change a unix path to a windows path

open file str.php in folder ./str

  • Synopsis:

    str::unix_dir(your_path)
str::unix_dir('D:\angel_home'); 
//return 'D:/angel_home'

Summary: Function accepts a unix path and returns an equavalent windows path.
Description: Function seeks for specific characters in unix path and replace them with equavalent characters in windows path. Then returns the modified path.


Getting Started

Data Structure

Networking

Operations

Features

Clone this wiki locally