/    Sign up×
Community /Pin to ProfileBookmark

How To Add All 4 Words Into Array With 4 Keys & Values ?

Folks,

Using explode() trying to add all 4 words into array but failing. Now you try …

[code]
<?php
$str = ‘one,two,three,four’;

// zero limit
print_r(explode(‘,’,$str,0));
print “<br>”;

// positive limit
print_r(explode(‘,’,$str,2));
print “<br>”;

// negative limit
print_r(explode(‘,’,$str,-1));
?>

</body>
</html>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@abdlimranFeb 28.2021 — Hi! I have tried this way :

``<i>
</i>&lt;?php
$str = 'one,two,three,four';


$newStr = explode(',',$str); //$newStr will return a array

// zero limit
$newStr2 = explode(',',$str,0);

// positive limit
$newStr3 = explode(',',$str,2);

//4 keys and values
list($first, $second, $third, $fourth) = explode(',',$str);

print_r($first);

echo("n");

?&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@daveyerwinFeb 28.2021 — to add all substrings into array don't use a limit
Copy linkTweet thisAlerts:
@developer_webauthorFeb 28.2021 — Thank you fellows!
×

Success!

Help @developer_web 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.24,
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,
)...