possible to split array element?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

possible to split array element?

Post by joecrack »

i have an array element that looks like this:

$data['0']=12.34.8888

Now i would like to splitt this element into:

$newdata1['0']=12.34.
$newdata2['0']=8888


Is that possible?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Yes it is possible using explode(), but can you expect the data to be in a certain format?

In your example you have x.x.x, and you want to split the first two from the third, so is there always going to be 2 decimals?
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

i will ALWAYS be the same format ...
thanks .. i solved it =)
Post Reply