Sunday, January 1, 2017

How to set custom comment limit for textarea like twitter

Do you want something like this


Checkout this video





Download Full Code


Friday, October 28, 2016

How to find how many parameter / Arguments has been passed and there value

code-
<?php
    function parentFunction($name='name') {
        echo "There are total: ".func_num_args()." Arguments passed.<BR>";
        $args = func_get_args();

echo '<pre>';
print_r($args);
echo '</pre>';

//fetch the value
        for($i = 0; $i < count($args); $i++) {
echo "Passed Value: {$args[$i]}<br />";
        }
      }
    parentFunction($name= 'name','email','phone','location');
?>

login authentcation via browser prompt using PHP




<?php
if (($_SERVER['PHP_AUTH_USER'] != 'a') || ($_SERVER['PHP_AUTH_PW'] != 'a')) {
      header('WWW-Authenticate: Basic Realm="Secret Stash"');
      header('HTTP/1.0 401 Unauthorized');
      print('You must provide the proper credentials!');
      exit;
   }
else{
echo 'login done';
//do stuff here
}
?>

Extract Only numbrs from long string using Regex with PHP (Regular Expressions)

Here is a string -: RT4646R@TWBNSN3234FHFHFH893892389FHDJJD$

Now How will find all red marked numbers in an Array.Here is solution.




<?php
$string = 'RT4646R@TWBNSN3234FHFHFH893892389FHDJJD$';
$special_char = '\[#$%^&*()+=\-\[\]\';,.\/{}|":<>?~\\\\]';
preg_match_all('/\d+/', $string,$output);

echo '<pre>';
print_r($output[0]);
?>






Here is the output

PHP Regular Expressions





Author - 
sudhir k gupta | sudhir gupta | sudhir kumar gupta | eghara
Sudhir K gupta | Lonawala

Tuesday, September 27, 2016

Convert All Table TD data into Titlecase with 1 line of code

Lets say.. you receive input from server and that input is unstructured. No proper title case. 


Just like this. 


And You want like this (in just one click or unload )



Here is the code (Copy link is below the screenshot)



Download Full Code From Here