Jump to content

[SOLVED] Is there a function in php?


ballhogjoni

Recommended Posts

Is there a function in php that will decode this to regular characters?

 

so instead of this:

\074\141\040\150\162\145\146\075\042$l1dt\042\076\074\142\076

 

It would be this:

<a href="$l1dt"><b>

 

I use the ascii table, and decode it by hand, but i want to write a program that will do it automatically.

Link to comment
https://forums.phpfreaks.com/topic/47571-solved-is-there-a-function-in-php/
Share on other sites

All of the characters are a little invalid... because I get the following string:

J(–¢‘’K*$l1dt*LJŽL

Doing this code:

<?php
$str = '\\074\\141\\040\\150\\162\\145\\146\\075\\042$l1dt\\042\\076\\074\\142\\076';

echo preg_replace_callback('/(\\\\[\d]{3})/', "replaceChar", $str);

function replaceChar($arr) {
	return chr(substr($arr[1], 1));
}
?>

this what your lookin for?

 

chr

(PHP 4, PHP 5)

 

chr — Return a specific character

 

Description

string chr ( int $ascii )

 

Returns a one-character string containing the character specified by ascii.

 

Example 2306. chr() example

 

<?php

$str = "The string ends in escape: ";

$str .= chr(27); /* add an escape character at the end of $str */

 

/* Often this is more useful */

 

$str = sprintf("The string ends in escape: %c", 27);

?>

 

 

 

You can find an ASCII-table over here: » http://www.asciitable.com.

 

This function complements ord(). See also sprintf() with a format string of %c.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.