Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

explode function doesn't work [closed]

Tags:

php

I have a String 7*10*6* I will separate the numbers, when I use explode function the out is:

Array
(
    [0] => *
)

here is my code:

echo '<pre>';
print_r(explode('7*10*6','*'));
echo '</pre>';

what's the problem?

like image 796
Micheal Taylor Avatar asked Mar 28 '26 18:03

Micheal Taylor


2 Answers

Oh boy, have you read the manual of explode? the manual says: explode(string $delimiter,string $string). You have done wrong. change your code to this:

print_r(explode('*','7*10*6'));
like image 161
Behzad Hassani Avatar answered Mar 30 '26 10:03

Behzad Hassani


Try

print_r(explode('*','7*10*6'));

In explode function first argument is separator and second is string.

like image 37
Devang Rathod Avatar answered Mar 30 '26 09:03

Devang Rathod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!