A
A
ant1vit2016-07-06 08:31:43
PHP
ant1vit, 2016-07-06 08:31:43

How to pass parameters to php array?

How to pass parameters from $a, $b, $c to $array? The sequence of variables is

<?php
$array = array(
 1 => $a,
 2 => $b,
 3 => $c,
);
$result = $array[2];  //дальше  мне надо будет работать с этими данными

//Ниже передаем параметры 
$a = 20;
$b = 30;
$c = 40;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
amikolyk, 2016-07-06
@amikolyk

$array = array(
    1 =>0,
    2 =>0,
    3 =>0,
);

$array[1]= &$a;
$array[2]= &$b;
$array[3]= &$c;

$a = 20;
$b = 30;
$c = 40;

or even easier
$array = array(
 1 => &$a,
 2 => &$b,
 3 => &$c,
);

$a = 20;
$b = 30;
$c = 40;

for the very bad
64379305e19448899bcfe602c0c088c2.png

A
Anton Fedoryan, 2016-07-06
@AnnTHony

write a function ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question