Find below code to get 2 values from every loop using PHP.
for ($i=0; $i<count($list_of_images)-1; $i+=2) {
echo $list_of_images[$i][‘img’];
echo $list_of_images[$i+1][‘img’];
}
Find below code to get 2 values from every loop using PHP.
for ($i=0; $i<count($list_of_images)-1; $i+=2) {
echo $list_of_images[$i][‘img’];
echo $list_of_images[$i+1][‘img’];
}
If we use typejs in our document this type of issue will occur find below code to fix.
$(“.textarea”).bind(‘keypress’, function(e) {
if(e.which == 32){
var textarea_val = $(“.textarea”),
val_ask = textarea_val.val();
textarea_val.focus().val(“”).val(val_ask);
}
});
/*Total website redirect to HTTPS*/ ExpiresActive On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] /*Redirect specific page to HTTPS*/ ExpiresActive On RewriteCond %{SERVER_PORT} 80 RewriteCond %{HTTPS} !=on [NC] RewriteCond %{REQUEST_URI} /page_path/ RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Find below code to check md5 encrypted password with submitted password.
$password = “avinash”;
$store_password = md5($password);
$submit_password =$_POST[‘submit_password’];
$sub_password = md5($submit_password);
if($sub_password==$store_password){
echo “Success password”;
}
array_slice function we will use for array pagination to get some part of array
$items = array(1,2,3,4,5,6,7,8,9,10);
$limit = 3;
$qty_items = count($items);
$qty_pages = ceil($qty_items / $limit);
$curr_page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
$next_page = $curr_page < $qty_pages ? $curr_page + 1 : null;
$prev_page = $curr_page > 1 ? $curr_page – 1 : null;
$offset = ($curr_page – 1) * $limit;
$items = array_slice($items, $offset, $limit);
$items // Array of elements
$offset // how many elements leave at the time of fetching
$limit //get number of elements from array
Pagination code
for($i = 1; $i <= $qty_pages; $i++){
echo $i;
}
ceil() function return integer number.
// Page not found
if ( is_404() ) {
;
}
// Front page
if ( is_front_page() ) {
;
}
// Archive
if ( is_archive() ) {
;
}
// Blog Page
is_page(‘blog’) {
;
}
// Search
if ( is_search() ) {
;
}
// Singular
if ( is_single() ) {
;
}
// Home
if ( is_home() ) {
;
}
Please find below code to change label & placeholder in woo-commerce checkout billing form
add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
function custom_override_checkout_fields( $fields ) {
unset($fields[‘billing’][‘billing_last_name’]);
$fields[‘billing’][‘billing_first_name’][‘placeholder’] = ‘Contact Name’;
$fields[‘billing’][‘billing_first_name’][‘label’] = ‘Contact Name’;
return $fields;
}
When getting this type of issue please check site SSL is enable or not.
Stripe is enabled, but the force SSL option is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate – Stripe will only work in test mode.
Please find below code for remove files and directories using PHP.
$folder = “test/test2/test3”; or $folder = “test/test.txt”;
deleteDirectory($folder);
function deleteDirectory($dir) {
if (!file_exists($dir)) { return true; }
if (!is_dir($dir) || is_link($dir)) {
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == ‘.’ || $item == ‘..’) { continue; }
if (!deleteDirectory($dir . “/” . $item, false)) {
chmod($dir . “/” . $item, 0777);
if (!deleteDirectory($dir . “/” . $item, false)) return false;
};
}
return rmdir($dir);
}