Answers for "php array"

4

php array

<?php
$array = array(
    "foo" => "bar",
    42    => 24,
    "multi" => array(
         "dimensional" => array(
             "array" => "foo"
         )
    )
);

var_dump($array["foo"]);
var_dump($array[42]);
var_dump($array["multi"]["dimensional"]["array"]);
?>
Posted by: Guest on June-17-2020
3

php array

<?php
$array = array("foo", "bar", "hello", "world");
var_dump($array);
?>
Posted by: Guest on June-17-2020
0

php array

$cars = array('BMW', 'Ferrari', 'Honda');

$str= implode(', ', $cars);
echo $str;                  //array to string

$arr = explode(', ', $str);
echo json_encode($arr);     //string to array
Posted by: Guest on August-17-2021
0

php array

<html>
   <body>
   
      <?php
         /* First method to create array. */
         $numbers = array( 1, 2, 3, 4, 5);
         
         foreach( $numbers as $value ) {
            echo "Value is $value <br />";
         }
         
         /* Second method to create array. */
         $numbers[0] = "one";
         $numbers[1] = "two";
         $numbers[2] = "three";
         $numbers[3] = "four";
         $numbers[4] = "five";
         
         foreach( $numbers as $value ) {
            echo "Value is $value <br />";
         }
      ?>
      
   </body>
</html>
Posted by: Guest on May-19-2021
0

php array

$array = [];
Posted by: Guest on April-14-2021
1

PHP Array

<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
Posted by: Guest on April-02-2020
0

php array

<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// Using the short array syntax
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
?>
Posted by: Guest on February-15-2021
0

php array

$a = array(0,1,2);
Posted by: Guest on September-12-2021
0

php array

<html>
   <body>
   
  
  555
      <?php
         /* First method to create array. */
         $numbers = array( 1, 2, 3, 4, 5);
         
         foreach( $numbers as $value ) {
            echo "Value is $value <br />";
         }
         
         /* Second method to create array. */
         $numbers[0] = "one";
         $numbers[1] = "two";
         $numbers[2] = "three";
         $numbers[3] = "four";
         $numbers[4] = "five";
         
         foreach( $numbers as $value ) {
            echo "Value is $value <br />";
         }
      ?>
      
   </body>
</html>
Posted by: Guest on May-19-2021
0

php array

array (
  0 => '1',
  1 => '2',
  2 => '3',
  3 => '4',
)
Posted by: Guest on July-23-2021

Browse Popular Code Answers by Language