Category : PHP


How to get minimum key value of array in PHP?

Sometimes, you need to get minimum key value of your array but you try to get with loop and any function etc, but in bellow example you can see we can get smallest key value from our php array by using min() and array_keys(). So, let's try to use in your code this way: <strong>Example:</strong> <pre class="language-php"> $myArray = ['2'=>'Hey','4'=>'Hello','1'=>'Hi','3'=>'GH']; $new_key = min(array_keys($myArray)); $new_val = $myArray[$new_key]; print_r($new_val); </pre>

By Hardik Savani | February 12, 2016 | | 684 Viewer | Category : PHP
READ MORE

How to set scroll to bottom in jquery?

Sometimes, we need to set scroll bottom as default by using jquery, in bellow example you can see i use scrollHeight for get the total height of scroll class div with scroll, and at last i use animate with scrollTop attribute and set bottom, So Basically when your page will load then automatically scroll as bottom. <strong>Example:</strong> <pre class="code language-html"> <html lang="en"> <head> <title>Scroll Down bottom</title> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <div cl.....

By Hardik Savani | February 11, 2016 | | 1876 Viewer | Category : PHP
READ MORE

How can i print php variable in jquery?

If you are working on php and you need to print your php variable inside the javascript then you can simple get value. you can use "" for get value of php variable. in following example you can see : <strong>Example:</strong> <pre class="code language-html"> <script type="text/javascript"> var my_var = "<?php echo $my_variable; ?>"; console.log(my_var); </script> OR <script type="text/javascript"> var my_var = <?php echo $my_variable; ?>; console.log(my_var); </script> </pre> But, you can use on php file, Not on js file.

By Hardik Savani | February 8, 2016 | | 1186 Viewer | Category : PHP
READ MORE

How to get product using rakuten marketing api in PHP?

In this post you can find how can use rakuten linkshare API in our php website. first you need to create class for retrieve data from "https://pubhelp.rakutenmarketing.com/hc/en-us" website. now i give to example of product search, but if you use this class then you can easy to implement your other search like advance search etc. So now i am giving you class that send request to rakutenmarketing.com website and get data. but this class you can also you for other site API use like CJ API. <strong>Your php file :</strong> <pre class="language-php"> public function getProduct() { // Bearer to.....

By Hardik Savani | February 6, 2016 | | 6189 Viewer | Category : PHP
READ MORE

PHP: How to count files in folder?

In PHP, you are work on php and you want to need display count number of files in specific folder then you do, glob() through you count number of file are there in specified folder. now in following example you can see "/var/www/test" in this folder, count how many files are there in that folder. glob function take a two argument first one for directory or folder path and second argument for filter. Filter means if you pass '*' then it will count all type of file, i mean all extension, but if you need to count just text file then you can put like '*.txt'. That't it, if in your directory, func.....

By Hardik Savani | February 4, 2016 | | 2083 Viewer | Category : PHP
READ MORE

How to find day from specific date in PHP?

Whenever you need to det day like Monday, Tuesday etc from full date. i mean you have any specific date like "2015-10-10" and you want to get day then you can do in both way first using strtotime() and second using DateTime object. In Following example you can see i give you both way to get day from your date. now i added format 'l' so it will return full name of day like "Tuesday", but if you want to get short name of day then you can change format like "D". <pre class="language-php"> // Using strtotime() $specificDate = strtotime('2016-2-3'); $specificDate = date('l', $specificDate); var_d.....

By Hardik Savani | February 3, 2016 | | 781 Viewer | Category : PHP
READ MORE

How to check empty or null in Mysql Query?

If you want to check empty or null value with conditional statement like case when and if in table row with Mysql database. you like to check empty or null value form table then you have multiple way check that. first we check empty value with case when statement then following example. <strong>Empty Check:</strong> <pre class="language-mysql"> SELECT (CASE WHEN COALESCE(email,'')!='' THEN email ELSE 'example@gmail.com' END) as test FROM `customers` ---------------------OR---------------------- SELECT (CASE COALESCE(email,'') WHEN '' THEN 'example@gmail.com' ELSE email END) as test FR.....

By Hardik Savani | January 31, 2016 | | 953 Viewer | Category : PHP
READ MORE

How to copy one table data into another table using Mysql Query?

If you are working on php or any php framwork and you want to copy one table into other table by using sql query, so you could do it using simple SELECT and INSERT statement. just you need to think how you can use. In Following example you can see how to fetch data from "post" table and how to insert into "post_copy" table, so basically you have to select field of one that you want to copy and second one give name of table with proper field that you want insert. But don't forgot to give a name of field otherwise it generate error. <pre class="language-mysql"> INSERT INTO `post_copy` (name,sl.....

By Hardik Savani | January 30, 2016 | | 2153 Viewer | Category : PHP
READ MORE

How to remove null values from array in PHP?

you have array with null value and you want to remove all null value from that array without loop. you can remove your all null value from array without loop. PHP array_filter function through you can remove all null value, you see following example how to remove null value : <strong>Example:</strong> <pre class="language-php"> $example = array(100, "hardik", null, "hey", NULL, "", 77); $result = array_filter($example, function($value) { return !is_null($value); }); print_r($result); </pre> <strong>Output:</strong> <pre>Array ( [0] => 100 [1] => hardik [3] => hey [5.....

By Hardik Savani | January 28, 2016 | | 2466 Viewer | Category : PHP
READ MORE

How to Solve overwrite index.php in windows wampserver ?

Many time you have face a problem in windows wampserver or virtualhost of index.php file overwrite. i also fetch that problem like: http://localhost/test/index.php/admin In this url you can see index.php wtite in url, but URL must be without index.php. so if you are using windows wampserver then you can easily solve out this problem by folowing step: <strong>1. Open File : </strong>C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf <strong>2. Find : </strong> #LoadModule rewrite_module modules/mod_rewrite.so and Then, Just Change, Only remove ‘#’ sign. <pre> #LoadModule rewrite_module mo.....

By Hardik Savani | January 23, 2016 | | 1400 Viewer | Category : PHP
READ MORE

    How to connect mysql database in node js with example?

    How to connect mysql database in node js with example?

    Open Post

    Codeigniter - Dynamic dependent dropdown using jquery ajax Example

    Codeigniter - Dynamic dependent dropdown using jquery ajax Example

    Open Post

    Laravel 5 Autocomplete using Bootstrap Typeahead JS Example with Demo

    Laravel 5 Autocomplete using Bootstrap Typeahead JS Example with Demo

    Open Post

    Laravel 5 - whereIn and whereNotIn with subquery example using query builder

    Laravel 5 - whereIn and whereNotIn with subquery example using query builder

    Open Post

    Laravel 5.4 - send email using Markdown Mailables

    Laravel 5.4 - send email using Markdown Mailables

    Open Post

    How to integrate jQuery Fullcalendar using Bootstrap, PHP and MySQL ?

    How to integrate jQuery Fullcalendar using Bootstrap, PHP and MySQL ?

    Open Post