L
L
Lenz0072015-09-14 13:39:00
PHP
Lenz007, 2015-09-14 13:39:00

Is it possible to replace calls to an array with its values ​​in PHP?

There is an array with a whole bunch of cells that is called in order throughout the program, that is, mass[1], mass[2] ... mass[500]. Is it possible to somehow quickly change all these calls to cell values?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2015-09-14
@Lenz007

$GLOBALS['GLBL'] = array(
    base64_decode('c3RyX3Jlc' . 'G' . 'xhY2U='),
    base64_decode('ZmlsZV9nZXR' . 'f' . 'Y' . '29udGVudH' . 'M='),
    // ...
);

$content = <<<'FILE'
<содержимое файла>
FILE;
echo preg_replace_callback('/\$GLOBALS\[\'GLBL\'\]\[(\d+)\]/m', function ($m) use ($GLOBALS) {
    return $GLOBALS['GLBL'][intval($m[1])];
}, $content);

Here's what happened: pastebin.com/vkN3e0Uq

T
Talgat Baltasov, 2015-09-14
@talgatbaltasov

php.net/manual/en/function.array-flip.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question