Get the value $1 of preg_replace inside an array that has a function execution inside

Asked

Viewed 24 times

0

Well, I want to change a text from one sentence to another (it’s like an encryption)

code being used:

$dd = array();

$UserInfo = new UserInfo;

$search = array(
    '/log\((.*)\);/'
);

$replace = array(
    'log("' . $UserInfo->encrypt_text('$1', $dd) . '");'
);

$buffer = preg_replace($search, $replace, $buffer);

What I’m willing to do is this... if the phrase is:

log("Ola");

i want to take this part of ( Hello ) and send in that function down there to run the Cryptography, if I use the $1 outside the function, works normal, but when put in does not work

From now on, thank you

  • Oops, I put this function and it didn’t work :/ the problem seems to be in the form that I inserted $1 in the second array, but I tried anyway :/

  • @Valdeirpsr Are you unable to answer? I have noticed that you only comment.

  • @dvd There are no problems (technical) in responding. Only one of the ways to respond them quickly (in some cases).

  • @Snowrunescape This would be https://ideone.com/vq7EzF ?

  • @Valdeirpsr Psr, It worked, thank you very much :)

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.