Answers for "in_array Associative Array PHP"

PHP
16

Associative array in php

<?php 
/* 
There are 3 Types of array in php  
1. Indexed arrays - Arrays with a numeric index
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays

This is the second one - Associative arrays
*/

$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
echo "Mr.Samy is " . $age['Samy'] . " years old.";

?>
Posted by: Guest on June-10-2020
0

php associative array

<?php
$arr = array('fruit' => 'mango', 'vegetable' => 'tomato', 'thing' => 'bag');
echo $arr['fruit'];
/*OUTPUT
mango*/
?>
Posted by: Guest on April-24-2021
0

php associative array

<?php
$arr = array('fruit' => 'mango', 'vegetable' => 'tomato', 'thing' => 'bag');
echo $arr['fruit']
/*OUTPUT
mango*/
?>
Posted by: Guest on April-24-2021
0

php associative array

<?php
$arr = array('fruit' => 'mango', 'vegetable' => 'tomato', 'thing' => 'bag');
echo $arr['fruit'];
/*OUTPUT
mango*/
?>
Posted by: Guest on April-24-2021
0

associative array php

// Associative Array in PHP

/******** ARRAY TYPES  ************************************************
There are basically 03 Types of array in php  
1. Indexed arrays          => Arrays with a numeric index
2. Associative arrays      => Arrays with named keys
3. Multidimensional arrays => Arrays containing one or more arrays
***********************************************************************/

//EXAMPLE
//This is the second one - Associative arrays

$age = array("Peter"=>"35", "Naveen"=>"37", "Amit"=>"43");
echo "Mr.Samy is " . $age['Peter'] . " years old.";
Posted by: Guest on March-05-2021
0

in_array Associative Array PHP

$arr = array('lang1' => 'php','lang2' => 'java','lang3' => 'python');

if ( in_array( 'java', $arr ) ) {

  echo 'exists';

}else{

  echo 'not exists';

}
Posted by: Guest on October-09-2021

Browse Popular Code Answers by Language