Common, PHP

PHP script to unzip file

Hello friends here is the php script to unzip .zip files.

<?php
$zip = new ZipArchive;
$res = $zip->open(‘latest.zip’);
if ($res === TRUE) {
$zip->extractTo(‘./’);
$zip->close();
echo ‘woot!’;
} else {
echo ‘doh!’;
}
?>

Algorithms, PHP

Php program for insertion sort, Easy implementation

Php program for insertion sort. Easy implementation.

here is the link just try once https://github.com/vishvendrasingh/insertion_sort

<?php
/**Function for sorting an array with insertion sort algorithm.
*
* @param array $array
* @return array
*/
function insertionSort(array $array) {
$length=count($array);
for ($i=1;$i<$length;$i++) {
$element=$array[$i];
$j=$i;
while($j>0 && $array[$j-1]>$element) {
//move value to right and key to previous smaller index
$array[$j]=$array[$j-1];
$j=$j-1;
}
//put the element at index $j
$array[$j]=$element;
}
return $array;
}
$array = range(0, 19);
shuffle($array);
var_dump($array);
$arr = insertionSort($array);
var_dump($arr);
?>

here is the link just try once https://github.com/vishvendrasingh/insertion_sort

Common, wordpress

Backup & Restore wordpress from localhost to Remote Server

Recently I stuck in the middle. I had completed the wordpress theme in wamp(Windows), and now I wanted to move it to cPanel (linux). And the had full path like C:\wamp\www. Now when I uploaded this theme to server, the uploaded version of it was totally distorted.
I tried different approaches to solve this problem like find & replace & many other efforts.
But after all they did not worked for all the problem of path in option table for wordpress database.
Then I found this plugin https://wordpress.org/plugins/wp-clone-by-wp-academy/ that makes copy of your database now you need to install this plugin.
Secondly you have to create a backup of your wordpress. Then It will give you a link of zip archive. Now upload that link to your server.
To restore this backup into the Remote Server just give the link like this http://your-domain.com/path-to-link.zip.
And just click the upload you will see the same wordpress will is restored in remote server also.

Common, wordpress

Need to Increase Word Press memory

Need to Increase Word Press memory  Edit this file here – wp-includes/default-constants.php


// set memory limits
if ( !defined('WP_MEMORY_LIMIT') ) {
if ( is_multisite() ) {
define('WP_MEMORY_LIMIT', '64M');
} else {
define('WP_MEMORY_LIMIT', '40M');
}
}

 

change 40 to some other value