PHP String Concatenate Variable and Array Example

Hello Dev,

Right this moment, i we are going to present you php string concatenate, variable and array instance. This text offers you easy instance of php string concatenate, variable and array instance. you’ll be taught php string concatenate, variable and array instance.

Php is supplied to the 2 varieties of Concatenation (“.”),(‘.=’) to

So let’s observe few step to create instance of php string concatenate, variable and array instance.

(“.”) Operator


 The dot concatenation operator in PHP concatenate  proper and left arguments.

(‘.=’) Operator


 This second concatenation operator helps within the enlargement of the correct aspect argument to the left aspect argument.

Concatenate Two Strings & Variables In PHP Instance


 <?php
    $string1 = 'John';
    $string2 = 'shina';
    $name_str = $string1 . ' ' . $string2;
    echo $name_str;
?>

Output:


 John shina

Concatenating Variable With String In PHP Instance


 <?php
    $var = "Hey";
    echo $var.' World';
?>

Output:


 Hey World

Concatenate Two Arrays In PHP Instance


 <?php
    $myArr = array(1, "television" => "ac", 2, "washer", 3);
    $mySecondArr = array("phrase", "abc", "vegetable" => "tomato", "state" => "washington dc");

    $output = array_merge($myArr, $mySecondArr);
    print_r($output);
?>

Output:


Array

(

    [0] => 1

    [tv] => ac

    [1] => 2

    [2] => washer

    [3] => 3

    [4] => phrase

    [5] => abc

    [vegetable] => tomato

    [state] => washington dc

)

Now you’ll be able to verify your personal.

I hope it could show you how to…

Komentar

Postingan populer dari blog ini

Laravel 8 Get HTTP Hostname

JQuery Drag And Drop Menu Example

Laravel 8 Share Social Media Button