Fredric Posted March 12, 2007 Share Posted March 12, 2007 Hello there. Currently i have various data in a string like this: 351#Klimbo#Sogndal#1998#Xcim#4#mim 352#Dimbo#Ålesund#1998#Dixco#1#min 353#Zimbo#Oslo#1998#Frixo#2#mim 354#Crimbo#Oslo#1998#Crispo#2#mim 355#Finbo#Porsgrunn#1998#Nicey#1#min As you can see the data is separated by the "#" sign. Lets take a look at line 1 first: 351#Klimbo#Sogndal#1998#Xcim#4#mim What I want to do is put the data found in column 5 (Xcim) to change place with the data in column 4 (1998). So the output would be like this: 351#Klimbo#Sogndal#Xcim#1998#4#mim I want this to be repeated on all lines. Criterias. Only PHP 4.x functions can be used. Hope someone can help me with this, I have been wondering about this problem for quite some time now! I cant get it out of my head ??? Link to comment https://forums.phpfreaks.com/topic/42352-solved-move-data-with-stealth/ Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 <?php function domove($str) { $tmp = explode('#',$str); return $tmp[0].$tmp[2].$tmp[4].$tmp[3].$tmp[5]; } $oldstring = '351#Klimbo#Sogndal#1998#Xcim#4#mim'; $newstring = domove($oldstring); echo $oldstring."\n"; echo $newstring."\n"; ?> Link to comment https://forums.phpfreaks.com/topic/42352-solved-move-data-with-stealth/#findComment-205438 Share on other sites More sharing options...
Fredric Posted March 12, 2007 Author Share Posted March 12, 2007 Thanks a ton!. I cant believe i diden't see the answer. Link to comment https://forums.phpfreaks.com/topic/42352-solved-move-data-with-stealth/#findComment-205443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.