S
S
spido2021-07-01 22:34:21
PHP
spido, 2021-07-01 22:34:21

How to properly insert variables into an array?

Greetings!
There is an array in which you need to insert variables with values.

//Для примера переменные:
$site_subdomen_domen = 'www.yandex.ru';
$site_name_url = 'yandex.ru';
//Вставляю в массив
$allowedDomains = [
  "site_subdomen_domen",
        "site_name_url"
    ];

I expect to get the result:
$allowedDomains = [
  "www.yandex.ru",
        "yandex.ru"
    ];

But the values ​​of the variables are not written into the array.
What am I doing wrong?
Thanks in advance for any help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
N, 2021-07-01
@spido

<?php

$allowedDomains = [
  $site_subdomen_domen,
  $site_name_url
];

P
Pavel Shvedov, 2021-07-01
@mmmaaak

I would start by learning the basics and syntax of the language

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question