What do you want to save?
Add Code snippet
New code examples
-
PHP 2022-03-24 01:20:09
how to run foreach for the entire array except for one line in php
There are multiple ways of approaching this problem. The first solution is to use a flag boolean to indicate the first element and proceed in your foreach $firstElement = true; foreach($array as $key => $val) { if($firstElement) { $firstEl... Add solution -
PHP 2021-11-17 19:58:14
php collapse common columns in associative array
/* Collapse on common columns which is also the new key e.g. ([0] => [[id] => 1234, [firstName] => "foo", [1] => [[id] => 1234, [lastName] => "bar") will become ([1234] => [[firstName] => "foo", [lastN... Add solution -
Javascript 2021-11-13 21:08:11
wordpress ajax filter code
add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE} add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function'); function misha_filter_function(){ $args = array( 'orderby' => 'date', // we will sort posts by ... Add solution -
Javascript 2021-10-28 01:58:07
array sorting javascript mergesort
// Merge Sort (Recursive) function mergeSort (unsortedArray) { // No need to sort the array if the array only has one element or empty if (unsortedArray.length <= 1) { return unsortedArray; } // In order to divide the array in half, we need... Add solution -
PHP 2021-09-15 15:24:01
php extract email address from string
<?php function fetch_mails($text){ //String that recognizes an e-mail $str = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; preg_match_all($str, $text, $out); //return a blank array if not true otherwise insert the email in... Add solution
Best helpers
Ranking is empty