PHP code example of maksuco / helpers

1. Go to this page and download the library: Download maksuco/helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maksuco / helpers example snippets



//In laravel
\Helpers::mobile();
//In php
$helpers = new \Maksuco\Helpers\Helpers();
$helpers->mobile();
//use Illuminate\Support\Facades\Helpers;


  \Helpers::agent($mobile,$table,$desktop);

  \Helpers::mobile();
  //Returns true or false

  \Helpers::browserLocale(['en','es']);

  \Helpers::user_agent();
  //Returns Array ( [desktop] => 1 [mobile] => [tablet] =>  [device] => desktop [browser] => Chrome [os] => Macintosh [result] => Macintosh Chrome )
  //Returns ['lang'], and ['estimate']=true if is not exact data

  \Helpers::botDetected();
  //Returns true or false


  $img = \Helpers::avatar($user);
  OR
  {{\Helpers::avatar($user->email)}}



  {{\Helpers::firstname($fullname)}}
  //Gina Gutierrez returns Gina
  //Gi Gutierrez returns Gi Gutierrez



  {{\Helpers::initials($fullname)}}
  //SEND Sofia Loren
  //GET SL



  //SEND
  $security = Helpers::encrypt($string,$key);
  //AFTER
  $string = Helpers::decrypt($security,$key);
  //CONVERT LETTERS TO NUMBERS
  $string = Helpers::lettersToNumbers($string,$phone=false);



  {{\Helpers::nav_active($page)}}
  //SEND: nav_active('about')
  //RETURNS: 'active'



  {{\Helpers::text_parse($text,$blank)}}
  //SEND: Welcome to http:://apple.com
  //RETURNS: Welcome to <a href="http:://apple.com">http:://apple.com</a>



  {{\Helpers::getTextBetween($text,$start,$end)}}
  If you want to replace the text between two strings use
  {{\Helpers::replaceTextBetween($text,$start,$end,$replace)}}



  {{\Helpers::countries('en')}}
  //RETURNS: Array
  {{\Helpers::country('US')}}
  //RETURNS: "id": 241,"code": "US","name_en": "United States","name_es": "Estados Unidos","status": null,"tel": 1,"lang": "en","currency": "USD","currency_symbol": "$","timezone_group": null



  {{\Helpers::cities('US')}}
  //RETURNS:"name": "Salta","region": "A","country": "AR","latitude": "-24.78835","longitude": "-65.41266","slug": "salta"


  {{\Helpers::continent('US')}}
  //RETURNS: 'america'
  {{\Helpers::continent('FR')}}
  //RETURNS: 'europe'


  {{\Helpers::timezones()}}
  //RETURNS: Array


  {{\Helpers::languages()}}
  //RETURNS: Array
  {{\Helpers::languages('en')}}
  //RETURNS: 'english'



  {{\Helpers::currencies()}}
  //RETURNS: Array of isoCodes
  {{\Helpers::currencies('complete')}}
  //RETURNS: Array of all currencies with: name, isoCode, symbol and other data
  {{\Helpers::currencies('usd')}}
  //RETURNS: All data of the currency
  {{\Helpers::currency_format('10000.00','usd',false)}}
  //'10000.00','usd' RETURNS: $10,000 usd
  //'100.30','usd' RETURNS: $100.30 usd
  //'10000.30','eur' RETURNS: 10.000,30 €
  //'10000.00','cop',true RETURNS: Array ["result" => "$10.000""symbol" => "$""htmlEntity" => "&#x20B1;""amount" => "10.000""isoCode" => "COP""symbolFirst" => true"decimalSeparator" => ",""thousandsSeparator" => "."]



  {{\Helpers::moneyFormat($value,$currency)}}
  //SEND: 1234.56,'EUR' RETURNS: €1,234.56
  //SEND: 1234.00,'USD' RETURNS: $1,234



  {{\Helpers::currency_exchange($amount, $from, $to, $round)}}
  //SEND: 1,'EUR','USD' RETURNS: 1,99 (SAMPLE)
  //SEND: 1,'EUR','USD',true RETURNS: 2 (SAMPLE)



  {{\Helpers::decimalsFormat($number)}}
  //SEND: 1,234.56 RETURNS: 1234.56
  //SEND: 1,234 RETURNS: 1234.00
  {{\Helpers::decimalsFormat($number,false)}} //NO CENTS
  //SEND: 1,234.560 RETURNS: 1234560
  //SEND: 1,234 RETURNS: 1234



  $location_data = \Helpers::geoip($ip); //\Helpers::geoip($ip,'option'); OR \Helpers::geoip($ip,'ipstack','my_ipstack_key');
  $location_data = \Helpers::geoipLaravel($ip); //\Helpers::geoip($ip,'option'); OR \Helpers::geoip($ip,'ipstack','my_ipstack_key');



  \Helpers::timezone($ip,Carbon::now());


  $distance = \Helpers::distance($lat1, $lon1, $lat2, $lon2, $unit = "K");


  \Helpers::appendtojson($json,$new,$subcategory,$limit)



  \Helpers::csvstring($action,$data,$new)



  \Helpers::array_process($action,$array,$new)

	//$array = ['michael','gina'];
  //array_process('add',$array,'bob') returns ['michael','gina','bob']

  //array_process('remove',$array,'michael') returns ['gina']

  //array_process('invert',$array,'michael') returns "removed" MALLLLLLl
  
  //Associative
	//$array = ['michael'=>'m'];
	//$new = ['michael'=>'something','donald'=>'duck','bob'=>'m'];
  //array_process('add',$array2,$new2) returns ['michael'=>'something','donald'=>'duck','bob'=>'m']
  
	//array_process('check',$array,'gina') returns TRUE


  \Helpers::collection_relation($principal_collection,$second_collection,$second_relation_column,['new_column'=>'second_column_name'],$principal_relation_column)

  {{(\Helpers::column_check($data,$value))? 'YES!':'NO!'}} //($user->favorites,124)

  \Helpers::column_process($data,$table,$column,$value) //($user,'users','favorites',124)


  {{\Helpers::link($account->domain)}}
  //SEND: somedomain.com
  //RETURNS: http://somedomain.com
  //SEND: mailto:xxxx
  //RETURNS: mailto:xxxx



  $domain = \Helpers::domain_from_email($email);
  //returns the domain from an email if it's not a free service like gmail.com, else it returns false



  $domain = \Helpers::domain_from_url($url);
  //returns the domain.com from http://www.domain.com/something
  \Helpers::domain_from_url($url,true); //subdomain true
  //returns the account.domain.com from http://account.domain.com/something


  $domain = \Helpers::url_html($url);
  //returns the body content of url
	$domain = \Helpers::url_html($url,'div');
	//returns a string with first div content
	$domain = \Helpers::url_html($url,'#home',true);
	//returns the section with id="home" and true converts all img src and links href to full urls.
	//using id selects the entire section, using elements only selects the content.


  {{\Helpers::telto($phone)}}
  //SEND: +1 (305) 890 8989
  //RETURNS: 13058908989



  {{\Helpers::getVideoID($provider,$string)}}
  //SEND: 'youtube','https://www.youtube.com/watch?v=12345'
  //RETURNS: 12345
  //SEND: 'youtube','12345'
  //RETURNS: 12345
  //SEND: null,'https://host.com/file.mp4'
  //RETURNS: https://host.com/file.mp4



  if(\Helpers::email_check($email)) {}
  //returns if the email is valid: true or false
  //Also checks if the domain exist
  OR

  if(\Helpers::domain_check($email)) {}
  //returns the domain from the email and checks if it exist
  OR
  if(\Helpers::domain_check('maksuco.com')) {}
  //Checks if the domain exist


  \Helpers::getFileType('xxx.mov');
  //returns video

  \Helpers::sizetobytes('1 mb');
  //returns xxxx bytes

  \Helpers::random(4);
  //returns 4 letters mix with numbers
  \Helpers::random(4,true);
  //if you want only numbers
  \Helpers::random(4,false);
  //if you want only letters

  \Helpers::random_name($type);
  //returns John

  \Helpers::random_quote();
  //returns Something special

  \Helpers::hide_string($string);
  //returns 3234****9099
  \Helpers::hide_string($string, $middle = 'xx');
  //returns 3234xx9099
  \Helpers::hide_string('455667867897', $middle = 'xxddd','start');
  //returns with 'start' 4556xxddd
  //returns with 'end' xxddd7897

  \Helpers::greetings_by_time($timezone);
  //Returns: "Good morning", "Good afternoon", "Good evening" or "Good night"

  \Helpers::date_day($days_difference,$lang);
  //lang is optional


  $filename = \Helpers::filename('http://xxx.com/this_is_the_name.png?v=xxx');
  //RETURNS: this_is_the_name.png
  OR
  $filename = \Helpers::filename('http://yyyy.com/this_is_the_name.png',true);
  //RETURNS ARRAY: basename: this_is_the_name.png, extension: png, filename: this_is_the_name
  //USE: $filename->basename



  $slug = \Helpers::slug('Hi how are you? Muy@#$%^&*good');
  //RETURNS: hi-how-are-you-muy-good
  OR
  $slug = \Helpers::slug($name);



  $slug = \Helpers::slug_file('Hi how are you? Muy@#$%^&*good.jpg',0);
  //hi-how-are-you-muy-good.jpg
  OR
  $slug = \Helpers::slug_file($file->getClientOriginalName(),5);
  //hi-how-are-you-muy-good-hj567.jpg
  OR
  $slug = \Helpers::slug_file($filename,'great-doc');
  //hi-how-are-you-muy-good-great-doc.pdf



  $slug = \Helpers::slug_filename('SomeFile.jpg','new-name',0);
  //new-name.jpg
  OR
  $slug = \Helpers::slug_filename($file->getorriginalname(),'new-image',2);
  //new-image-9i.ext
  OR
  $slug = \Helpers::slug_filename($file,'one','great-images');
  //one-great-images.png



  $slug = \Helpers::slug_random('new-image');
  //new-image-hv8



  $slug = \Helpers::slug_username('Hi how are-you? Muy@#$%^&*good');
  //hihoware-youmuygood



  $slug = \Helpers::prepareCode($codeVariable);
  //SEND: <script>xxxx</script>
  //RETURNS: &lt;script>xxxx&lt;/script>


  {{\Helpers::facebookshare($url,$title,$app_id)}}

  {{\Helpers::twittershare($url,$title,$username)}}

  {{\Helpers::linkedinshare($url,$title,$username)}}

  {{\Helpers::pinterestshare($url,$title,$image)}}

  {{\Helpers::whatsappshare($url,$text)}}

  {{\Helpers::whatsappchat($phone,$url,$text)}}
  //\Helpers::whatsappchat('15551234xxx',null,'Im interested in your service')

  {!!\Helpers::popup()!!}

  {!!\Helpers::currenturl()!!}

  $html = \Helpers::minify_html($html);

  $media = \Helpers::instagram_process($instagram,'username');