Excellent Programming Tricks

Array | php

  1. Declare Simple Array (indexed arrays): $something = array(10, 20, 30);
    1. Display Second Element: echo $something[1];
    2. Output: 20.
  2. Declare Array and assign value
    1. $var = array();
    2. $var[] = 'deer';
  3. Declare Simple Array (associative arrays): $something = array(“a”=>10, “b”=>20, “c”=>30);
    1. Display Second Element: echo “I got “.$something[‘a’].” in Physics.”;
    2. Output: I got 10 in Physics.
  4. Find out the number of elements of an array is used by count() function : echo count($something);
  5. If only echo $something;
    1. Output: Array.
    2. User echo $something[0];
  6. $a = "Iftekhar";
    1. $something = (array) $a;
    2. echo $something[0];
    3. Output: Iftekhar.
  7. Marge array
    1. $defaults = array_merge( $defaults, array(
        'infinite-scroll' => array(
         'container'  => '.entries-wrapper',
          'total-posts' => $wp_query->found_posts,
         'posts-per-page'=> $wp_query->query_vars['posts_per_page'],
         'method'  => $settings['inf_scroll_method']
        )
  8. Change key to value and value to key of an Array
    1. $flipped  = array_flip($myArray);
  9. Marge a new value into Array
    1. $output[] = $abc
  10. Returns an array if containing the keys
    1. $curArray = array_keys('$myArray', 'galib');
  11. Specific value search
    1. Return TRUE/False
    2. Case-sensitive
    3. if( in_array( "mizan", $myArrat ) ){echo "Found"; }

No comments:

Post a Comment


Authentic аnd Excellent

Website

HTML Template

Wordpress Theme

Database applications

OR

Application services?

Excellent Programming Tricks (EPT) || Iftekhar-IT || We develops the Web applications and the WordPress templates. || Excellent Programming Tricks (EPT)

© 2020 Blogger Theme by Iftekhar IT || Excellent Programming Tricks

Execllent Programming Tricks. Powered by Blogger.