How do I replace using the following code?
ereg_replace('%Data_Index\[.\]%', $this->resultGData[$key ][\\1], $var)
I want to replace the number in [] %Data_Index
to $this->resultGData[$key ][\\1] same %Data_Index
and how ex %Data_Index[1] = $this->resultGData[$key][1], $var);
replace number in %Data_Index[...........] in []
to $this->resultGData[$key ][............] same number
Try the
preg_replace()function with theemodifier instead:Note that this function uses Perl-compatible regular expressions instead of POSIX-extended regular expression.