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
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));
}
?>

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.