/    Sign up×
Community /Pin to ProfileBookmark

Cram these together?

i think you can house these inside of each other, but I keep getting an
error when I try. Someone else want to whip em’ into shape?

Example:

[code=php]
$encode = strtr(base64_encode(addslashes(gzcompress(serialize($query_string),9))), ‘+/=’, ‘-_,’);
[/code]

Actual two code chunks

[code=php]
$decode = $_SERVER[‘QUERY_STRING’];
$decode = base64_decode($decode);
parse_str($decode, $noko);

and

$query_string = http_build_query($noko);
$query_string = preg_replace(‘/%5B(?:[0-9]|[1-9][0-9]+)%5D=/’, ‘=’, $query_string);
$encode = base64_encode($query_string);
[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@Dave_LaneJul 16.2009 — You may want to re-evaluate why you're trying to condense all of that code into one line. The existing snippets are much more readable than the one-liner. Readability is very important if you plan on revisiting this code later (or if you're handing it off for someone else to maintain).

That being said, I don't see anything blatantly wrong in your code. Have you tried googling the error message?
Copy linkTweet thisAlerts:
@NogDogJul 16.2009 — Also, what is the purpose of the base64_decode/encode() stuff? Are you sure you shouldn't be using urlencode()/urldecode() instead?

PS: I see on further inspection you're trying all sorts of zipping and stuff, guess I'm not real sure what you ultimately want to do here???
Copy linkTweet thisAlerts:
@JunkMaleJul 16.2009 — Trying to be a smarty pants by the looks of it... ?

I can not for the life of me see how using a function to compress something would help in a URI situation as Nog has pointed out.

It might help if you explain step by step what it is your trying to achieve and what the reasoning behind each step is for and maybe theirs someone who could help you by simplifying what your trying to do.
Copy linkTweet thisAlerts:
@ehimeauthorJul 16.2009 — It just compresses an array and shoots it on the tail end of a url.

keeping it in base64 scrambles i to the point that it doesn 't generate

xhtml strict warnings. Either way, it doesn't matter WHAT it does,

I know. It's all that counts. Just curious how to encapsulate it a

bit so it's easier to inject into a page on one line. Thanks for your

musing about what I'm doing here guys. ?

NoDog I think your confused with the example that I showed and

the functions I actually use. the second code block are the two

I'm actually using. The first is just an example of encapsulating.

Using the base64_encode makes the arrays non-readable to the

average person so I don't have to worry as much about the user

changing values in the url. My array controls image count, short

name, and long name. Editing those will give the webpage I'm

injecting into weird results.
×

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.6,
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,
)...