/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Strange error, no idea :(

I’m just playing with PHP and trying to make a string encoder (just for fun). The idea is that the encoded string looks like

[code]
qwlkjhdf lkjsdhflkjhjpgj%%11|2|21|22|11|9|5
[/code]

I have no problem encoding it, and how it is encoded has no relevance. The problem I have is with decoding. I have to have a variable containing what is before “%%” and an array containing each element from after the “%%”, splitted by “|”. I use this code:

[code]
$pattern = split(“%%”, $encodedString);
$data = $pattern[1];
$data = split(“|”, $data); //Line 25
$pattern = $pattern[0];
[/code]

$pattern represents what is before “%%”. $data should be the array I’m talking about, but on line 25 I get this error:

[code]
Warning: split(): REG_EMPTY in C:apache2triadhtdocsworknewencode.php on line 25
[/code]

Anyone has any ideas why this error occurs??

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Sid3335Nov 06.2006 — try explode() instead of split().

or alternatively:

[code=php]
$data = preg_split("/|/", $data, -1);
[/code]


or if you want to stick with split, you need to escape the | with a backslash:

[code=php]
$data = split("|", $data);
[/code]
Copy linkTweet thisAlerts:
@ZnupiauthorNov 06.2006 — Thanks! It worked ?
Copy linkTweet thisAlerts:
@pcthugNov 07.2006 — Marked Thread Resolved.
×

Success!

Help @Znupi 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.19,
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,
)...