Create an array with string that does not match a variable, and an array of variable names in PHP

Description

The following code shows how to create an array with string that does not match a variable, and an array of variable names.

Example


/*  w  w  w .  jav  a 2 s.  c o m*/
<?php
    $firstname = "XML";
    $lastname = "HTML";
    $age = "41";

    $name = array("firstname", "lastname");
    $result = compact($name, "location", "age");

    print_r($result);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone