Posts

Showing posts with the label PHP

php format date string short month

As you can see in our last example there are tons of different formats that can be used in the date feature. Below is a summary of the variable used in date, and what each does. Remember they ARE CaSe sEnsItIVe: DAYS   d - day of the month 2 digits (01-31)   j - day of the month (1-31)   D - 3 letter day (Mon - Sun)   l - full name of day (Monday - Sunday)   N - 1=Monday, 2=Tuesday, etc (1-7)   S - suffix for date (st, nd, rd)   w - 0=Sunday, 1=Monday (0-6)   z - day of the year (1=365) WEEK   W - week of the year (1-52) MONTH   F - Full name of month (January - December) m - 2 digit month number (01-12)   n - month number (1-12)   M - 3 letter month (Jan - Dec)   t - Days in the month (28-31) YEAR L - leap year (0 no, 1 yes) o - ISO-8601 year number (Ex. 1979, 2006) Y - four digit year (Ex. 1979, 2006) y - two digit year (Ex. 79, 06) TIME a - am or pm A - AM or PM B - Swatch Internet time (...

Attempting to understand handling regular expressions with php

Regular Expression, commonly known as RegEx is considered to be one of the most complex concepts. However, this is not really true. Unless you have worked with regular expressions before, when you look at a regular expression containing a sequence of special characters like /, $, ^, \, ?, *, etc., in combination with alphanumeric characters, you might think it a mess. RegEx is a kind of language and if you have learnt its symbols and understood their meaning, you would find it as the most useful tool in hand to solve many complex problems related to text searches. Just consider how you would make a search for files on your computer. You most likely use the ? and * characters to help find the files you're looking for. The ? character matches a single character in a file name, while the * matches zero or more characters. A pattern such as 'file?.txt' would find the following files: file1.txt filer.txt files.txt Using the * character inst...

Regular expression handler quicker learn in php

Regex quick reference [abc]     A single character: a, b or c [^abc]     Any single character but a, b, or c [a-z]     Any single character in the range a-z [a-zA-Z]     Any single character in the range a-z or A-Z ^     Start of line $     End of line \A     Start of string \z     End of string .     Any single character \s     Any whitespace character \S     Any non-whitespace character \d     Any digit \D     Any non-digit \w     Any word character (letter, number, underscore) \W     Any non-word character \b     Any word boundary character (...)     Capture everything enclosed (a|b)     a or b a?     Zero or one of a a*     Zero or more of a a+     One or more of a a{3}...

php email reader and notification though header parameters

down vote accepted For the reading confirmations: You have to add the X-Confirm-Reading-To header. X - Confirm - Reading - To : <address> For delivery confirmations: You have to add the Disposition-Notification-To header.

Authorize.net ARB class Automated recurring billing class

<?php class AuthnetARBException extends Exception {} class WP_Invoice_AuthnetARB { private $login; private $transkey; private $params = array(); private $sucess = false; private $error = true; var $xml; var $response; private $resultCode; private $code; private $text; private $subscrId; public function __construct() { $this->url = stripslashes(get_option("wp_invoice_recurring_gateway_url")); $this->login = stripslashes(get_option("wp_invoice_gateway_username")); $this->transkey = stripslashes(get_option("wp_invoice_gateway_tran_key")); } private function process($retries = 3) { $count = 0; while ($count < $retries) { $ch = curl_init(); //required for GoDaddy if(get_option('wp_invoice_using_godaddy') == 'yes') { curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt ($ch, CUR...

php image upload class file

<?php     class Uploader     {         private $destinationPath;         private $errorMessage;         private $extensions;         private $allowAll;         private $maxSize;         private $uploadName;         private $seqnence;         public $name='Uploader';         public $useTable    =false;         function setDir($path){             $this->destinationPath  =   $path;             $this->allowAll =   false;       ...

array pagination using php class

<?php   class pagination   {     var $page = 1; // Current Page     var $perPage = 10; // Items on each page, defaulted to 10     var $showFirstAndLast = false; // if you would like the first and last page options.         function generate($array, $perPage = 10)     {       // Assign the items per page variable       if (!empty($perPage))         $this->perPage = $perPage;             // Assign the page variable       if (!empty($_GET['page'])) {         $this->page = $_GET['page']; // using the get method       } else {         $this->page = 1; // if we don't have a page number then assume we are on the first page  ...

how to slider bar open using jquery

-----------------------------------------------------------------------------------------------  <script type="text/javascript" src="<?php bloginfo( 'template_url' ); ?>/js/jquery.min.js"></script> <script type="text/javascript">     $(document).ready(function(){         jQuery(".pull_feedback").toggle(function(){                 jQuery("#feedback").animate({left:"0px"});                 return false;             },             function(){                 jQuery("#feedback").animate({left:"-527px"});                   return false;          ...

javascrpt captcha

<html> <head> <title>Captcha</title>         <script type="text/javascript">    //Created / Generates the captcha function        function DrawCaptcha()     {        var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";        var string_length =6;        var randomstring = '';     for (var i=0; i<string_length; i++) {         var rnum = Math.floor(Math.random() * chars.length);         randomstring += chars.substring(rnum,rnum+1);           }                document.getElementById("txtCaptcha").value = randomstring     }     // Validate the Entered input aganist ...

how to sorting multiple array object in php

sorting multiple array object using php  function sort_arr_of_obj($array, $sortby, $direction='asc') {          $sortedArr = array();     $tmp_Array = array();          foreach($array as $k => $v) {         $tmp_Array[] = strtolower($v->$sortby);     }          if($direction=='asc'){         asort($tmp_Array);     }else{         arsort($tmp_Array);     }          foreach($tmp_Array as $k=>$tmp){         $sortedArr[] = $array[$k];     }          return $sortedArr; } $lowestsellerpricesort= sort_arr_of_obj($response->categories->category->items->product->offers->offer,'baseP...

how to sort multiple array in php

multiple array sorting using php  <?php $multiArray = Array(     Array("id" => 1, "name" => "Defg","add"=>"adstes"),     Array("id" => 4, "name" => "Abcd","add"=>"tes"),     Array("id" => 3, "name" => "Bcde","add"=>"des"),     Array("id" => 2, "name" => "Cdef","add"=>"cad")); function aasort (&$array, $key) {     $sorter=array();     $ret=array();     reset($array);     foreach ($array as $ii => $va) {         $sorter[$ii]=$va[$key];     }     asort($sorter);     foreach ($sorter as $ii => $va) {         $ret[$ii]=$array[$ii];     }     $array=$ret; } aasort($multiArray,"id"); echo "<pre>";print_r($multiArray); ?> multiple array sorting using php

select all data between two dates using mysql

SELECT * FROM `product` WHERE (createdate BETWEEN '2012-11-19 14:15:55' AND '2012-11-29 21:58:43'); Hope enjoy:)

htaccess allow access php specific file

<Files ~ "^piwik\.(js|php)|robots\.txt$">     Allow from all     Satisfy any </Files>

how to post data to other page using javascript and php

<script  language="javascript"> function postdatasend(data){ var pnamevalue=document.getElementById('prname'+data).value; var ppricevalue=document.getElementById('prprice'+data).value; var mapForm = document.createElement("form");     mapForm.target = "Map";     mapForm.method = "POST"; // or "post" if appropriate     mapForm.action = "showsingleproduct.php";     mapForm.target='_self'; var pname = document.createElement("input");     pname.type = "hidden";     pname.name = "proname";     pname.value = pnamevalue;        mapForm.appendChild(pname);     var pprice = document.createElement("input");     pprice.type = "hidden";     pprice.name = "proprice";     pprice.value = ppricevalue;        mapForm.appendChild(pprice);     document.body.a...

shopping.com api using php and xml parsing easily

#create a array pagination class page. <?php   class pagination   {     var $page = 1; // Current Page     var $perPage = 10; // Items on each page, defaulted to 10     var $showFirstAndLast = false; // if you would like the first and last page options.         function generate($array, $perPage = 10)     {       // Assign the items per page variable       if (!empty($perPage))         $this->perPage = $perPage;             // Assign the page variable       if (!empty($_GET['page'])) {         $this->page = $_GET['page']; // using the get method       } else {         $this->page = 1; // if we don't have a page number then ass...

how to add rows number using mysql query

select @ rownum :=@ rownum + 1 ‘rowid’ , p .* from menu p ,   ( SELECT @ rownum := 0 ) r order by id desc limit 10 ;

create dynamic main menu and sub menu using php and mysql

<?php CREATE TABLE `menu` (   `id` int(11) NOT NULL auto_increment,   `label` varchar(50) NOT NULL default '',   `link` varchar(100) NOT NULL default '#',   `parent` int(11) NOT NULL default '0',   `sort` int(11) default NULL,   PRIMARY KEY  (`id`)) ------------------------------------------------------------------------------------------------------ $mysql=mysql_connect('127.0.0.1','root',''); mysql_select_db('test',$mysql); function display_menu($parent, $level) {     $result = mysql_query("SELECT a.id, a.label, a.link, Deriv1.Count FROM `menu` a  LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent WHERE a.parent=" . $parent);     echo "<ul>";     while ($row = mysql_fetch_assoc($result)) {         if ($row['Count'] > 0) {             echo "...

wordpress custom page title set

 how to set custom page title in wordpress <?php function add_custom_title() {          <title>call bikash page title</title> } add_action('wp_head','add_custom_title'); ?>

create wsdl for sending email using soap and php

--------------------------create wsdl using my code simple php -------------------------------------------- <?php Author by bikash ranajn nayak require_once('../lib/nusoap.php'); $server = new nusoap_server; $server->configureWSDL('server', 'urn:server'); $server->wsdl->schemaTargetNamespace = 'urn:server';  $server->wsdl->addComplexType('Emailsend','complexType','struct','all','', array( 'To' => array('name' => 'ToEmailid','type' => 'xsd:int'), 'From' => array('name' => 'FromEmailid','type' => 'xsd:string'), 'Subject' => array('name' => 'Subject','type' => 'xsd:string'), 'Message' => array('name' => 'MessageBody','type' => 'xsd:string') )); $server->register('Emailsend',             array(...

json return using soap server and soap client using php

copy soap_server page like (index.php); ----------------------------------------------------------------------- require_once('../lib/nusoap.php'); $server = new nusoap_server; $server->configureWSDL('server', 'urn:server'); $server->wsdl->schemaTargetNamespace = 'urn:server'; $server->register('getrequest',             array('name' => 'xsd:string'),                    array('return' => 'xsd:string'),             'urn:server',             'urn:server#getrequest'); function getrequest($value,$address) {    $getval=array('name'=>$value,'address'=>$address);       return json_encode($getval);      } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DA...