/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Fatal error: Call to undefined function: str_split()

I get the error “Fatal error: Call to undefined function: str_split()” when I try to split a string. Here is the code:

[CODE]$filesstring = getfiles();
$filesarray = str_split($filesstring);[/CODE]

What’s my problem?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chazzyMay 31.2006 — what is get files? what does it return?
Copy linkTweet thisAlerts:
@shane_carrauthorMay 31.2006 — Okay, here's the entire code of the entire document:

[CODE]<?

// getfiles() function thanks to http://www.codingforums.com/showthread.php?t=71869

function getfiles($dirname=".") {
$pattern="(.html$)";
$files = "";
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)) {
$tempfiles = "$files $file";
echo "$tempfiles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|||||&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$files = $tempfiles;
}
}
closedir($handle);
}
return($files);
}
$filesstring = getfiles();
$filesarray = str_split($filesstring);
echo getfiles();
echo $filesstring;
echo $filesarray;

?>[/CODE]


Does that help?
Copy linkTweet thisAlerts:
@NogDogJun 01.2006 — str_split() is only available in PHP5, so I suspect the problem is you're running PHP4.x. Try using [url=http://www.php.net/explode]explode()[/url] instead.
Copy linkTweet thisAlerts:
@shane_carrauthorJun 01.2006 — You're brilliant!
×

Success!

Help @shane_carr 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 4.28,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...