简体   繁体   中英

How to save variable inside a database to use later

I don't know what to call this definition problem. I need to parse value from preg_match_all . before i get the value i want. I need to parse again the multidimensional array value return by preg_match_all .

The point is I need to reuse code with different value. The different only in variable $regex and $match[1][0] ; In my database I have 2 columns. Regex value is pattern regex to match. The second column is $match[1][0] variable. What is call the definition?

I don't want to pass value variable $match[1][0] . but the $match[1][0] . and use it later with loop.

<?php
$temporary = "$match[1][0]";

preg_match_all($regex, $source, $match);

$match = $temporary;    

echo $match;

你可以试试eval()函数。它用php代码运行一个字符串!

You can like this

 $match = [
    1 => [
        [1]
    ]
];
$temporary = '$match[1][0]';

$match = eval('return $match[1][0];');

var_dump($match);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM