/    Sign up×
Community /Pin to ProfileBookmark

Preg_replace replacing all lines instead of last line

Yah, I dunno why it’s doing this now?
String replace instead maybe? Quick
responses earn cookies ?

[code=php]
switch ($_POST[‘crypt’]) {
case ‘encrypt’:
$output = $_POST[‘phpCode’];
$output = normalize($output);

$output = encrypt($output);
$output = chunk_split($output, 85, “‘.rn'”);

$pattern = array(‘//’, ‘#.s*’#’);
$replace = array(”, ‘;’);

$output = preg_replace($pattern, $replace, $output);
echo “<br /><b style=’color:red;’>Cipher:</b><br />”;
echo “<textarea style=’width:99.3&#37;;background-color:#000;color:#0f0;’>’$output</textarea>”;
echo “<br />”;
[/code]

outputs this:

[code]
SNh+83TMn2lAxOwWksOsWJAwTH7rVU+H0oEVcc4TKrEzDTBB3ad03IVojKHM2TwHGOLtdJBJ5Ir7j3GxFf3EU’;W827YVQrne8leHf0SSrtAJ2QKEj53iq50GvN19jmhKwHUAKOt2ndNyFaIyhzNk8Bxji7XSQSeSK+49xsRX9xF’;FvNu2FEnloTLrPxXZLMH2Ga5XbiGmp6wnjH8Tf2scqJD5Povjdp3TchWiMoczZPAcY4u10kEnkivuPcbEV/cR’;RbzbthS7ACbZgJFqZ2LvG0+VkJiKbuJZy3BlBOPFloRHQCv8x3ad03IVojKHM2TwHGOLtdJBJ5Ir7j3GxFf3E’;UW827YWWEca3ziIXsU+doDEwQ/aEbMTA8VctXM3QYT0+reY3VN2ndNyFaIyhzNk8Bxji7XSQSeSK+49xsRX9x’;FFvNu2FNDhyt7tmGoSwlJ6qUL5Smizetl+a7f+lkA5j15hWQTk=’;
[/code]

instead of what I want which is this:

[code]
‘SNh+83TMn2lAxOwWksOsWJAwTH7rVU+H0oEVcc4TKrEzDTBB3ad03IVojKHM2TwHGOLtdJBJ5Ir7j3GxFf3EU’.
‘W827YVQrne8leHf0SSrtAJ2QKEj53iq50GvN19jmhKwHUAKOt2ndNyFaIyhzNk8Bxji7XSQSeSK+49xsRX9xF’.
‘FvNu2FEnloTLrPxXZLMH2Ga5XbiGmp6wnjH8Tf2scqJD5Povjdp3TchWiMoczZPAcY4u10kEnkivuPcbEV/cR’.
‘RbzbthS7ACbZgJFqZ2LvG0+VkJiKbuJZy3BlBOPFloRHQCv8x3ad03IVojKHM2TwHGOLtdJBJ5Ir7j3GxFf3E’.
‘UW827YWWEca3ziIXsU+doDEwQ/aEbMTA8VctXM3QYT0+reY3VN2ndNyFaIyhzNk8Bxji7XSQSeSK+49xsRX9x’.
‘FFvNu2FNDhyt7tmGoSwlJ6qUL5Smizetl+a7f+lkA5j15hWQTk=’;
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ehimeauthorNov 16.2009 — think I got it, used '#.s*'Z#'

looks like cookies goto me ?
×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...