Answers for "php array function"

PHP
1

common array methods php

if (count($arr) > 1) {
     ....
}
Posted by: Guest on June-12-2020
1

common array methods php

print_r(deep_delete_keys($arr,'country'));

function deep_delete_keys($arr, $keys) {
    if (!is_array($keys)) $keys = array($keys);
    $filteredArr = array_diff_key( $arr, array_flip( $keys ) );
    foreach ($filteredArr as &$val) {
        if (is_array($val)) {
            $val = deep_delete_keys($val, $keys);
        }
    }
    return $filteredArr;
}
Posted by: Guest on March-28-2020
1

create array in php

$my_array = array();
Posted by: Guest on March-30-2021
2

array in php

<?php

$cars = array("Maserati", "Porsche", "BMW");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>
Posted by: Guest on May-23-2020
0

array values php function

$fruits = ["m"=>"banana", "c"=>"Apple" , "a"=>"gray"];
$newArray = array_values($colors); //new Array with values $fruits array
echo "<pre>";
print_r( $newArray );



//output
Array
(
    [0] => banana
    [1] => gray
    [2] => blue
    [3] => num
)
Posted by: Guest on June-23-2021
0

array php

Array
(
    [0] => Array
        (
            [name] => phone
            [price] => 700
        )

    [1] => Array
        (
            [name] => note
            [price] => 20
        )

    [2] => Array
        (
            [name] => book
            [price] => 49
        )

)
Posted by: Guest on June-28-2021

Browse Popular Code Answers by Language