Skip to content

adrianTNT/TNT-PHP-Functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 

Repository files navigation

TNT-PHP-Functions

While working on different personal websites I noticed that I always need same kind of PHP functions (truncate text, resize images, etc) so I decided to keep a centralised location for them.

Many of them might need work, so feel free to improve/comment/etc.

Thanks.

Usage

Download file tnt_php_functions.php and include it in your php file with:

include("tnt_php_functions.php");

Then inside your call any of the included functions:

remove_var_from_url("a", "script.php?a=1&b=2");

(will return script.php?b=2).

Functions list

Make a post request

Make an array of values and post them to given URL, get reply like with get_url();

tnt_post_url('script.php', $post_data_array);

Add variable to url

Add a variable to an URL (that might already contain this or other variables) add_var_to_url($variable_name,$variable_value,$url_string);

Print time difference like "2 days ago"

Print a time like "10 seconds ago", "3 days ago", "2 years ago" out of a timestamp like 1490279856 timestamp_to_ago(1490279856);

See how long it took to execute any part of your code

Time how long different operations took on your website/script, get a timer for each, output is an array of all timers you used. Note that you can define more than one timer in your code, how long it takes to load users from db, how long it takes to then loop over an array of users, etc.
// start a timer
timer("my db query");

// put some code here that loads users from database

// call again to stop a timer
timer("my db query"); 

// prints total seconds: 0.123
echo $timer["my db query"];

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages