( … ) Variable-length argument lists

In programming, there are many ways to solve a problem. But, everyone likes to easy and short solution.

The reason of telling that, PHP has a syntax token that will make my day. This is called Argument unpacking token or Variable-length argument lists token. This is typed with three dots ( … ). This is safe to use for 5.6 or latest version. For example,

function sum( ...$numbers ) {
    $acc = 0;
    foreach ( $numbers as $n ) {
        $acc += $n;
    }
    return $acc;
}

echo sum( 1, 2, 3, 4 );

return output 10 as 1+2+3+4=10.

Homework on PHP array functions

In PHP, there are plenty of PHP function which are very handy to smoothly build a web application. Currently, I find of 82 array functions and 13 array sorting functions. May be count of functions will be increase on time.

Notes: I will write about all array functions as time being.

  1. array_change_key_case
    This function is self explanatory. It will change keys of an array, if keys are string.
    For one dimensional array, array_change_key_case() simply change the keys in uppercase or lowercase (default case). But, for multidimensional array it will be tricky. Following are both types array example
$simple_array = [
    'AppLe' => 'Mrinal',
    'OraNge' => 'Shuchy',
    'PeNut' => 'Sukla',
];
$convert_key_simple_array = array_change_key_case( $simple_array, CASE_UPPER);
print_r($convert_key_simple_array);

To change keys of multidimensional array use this function

Start Gatsby with WordPress

Gatsby is now a day’s roar in the progressive web app. In this post, we will develop a workflow to integrate Gatsby with WordPress.

To integrate WordPress with Gatsby, the first step is set pretty permalink in WordPress. This enables us to use RESTful API from Gatsby app.

Continue reading “Start Gatsby with WordPress”

Finish this React application and future plan

This is the last part of Create react app with GraphQL way of WordPress data

In this finishing part, we build this application for production and plan for the next development workflow.

Building an application with the help of npm is pretty simple. Run

npm run build

and upload the files in the build folder in the server. You can see our application at reactblog.mrinalbd.com/. Also, can see the code if any need https://github.com/mrinal013/reactblog

Awesome experience to build this simple application. I heard some roar of Gatsby. Within a few days, I am going to build some stuff with Gatsby with WordPress.