Jump to content

[SOLVED] Replace spaces


drisate

Recommended Posts

Hey guys i have a string that looks like this when it's submitted

 

1:3:4  	 Phoenix  (cybermaster7 )  	932
1:12:15 	Phoenix (Dealer ) 	577
1:15:4 	Phoenix (Dealer ) 	577
1:15:11 M 	Phoenix (cybermaster7 ) 	932
1:20:4 	Phoenix (cybermaster7 ) 	932
1:20:5 	Phoenix (greenmask ) 	1079
1:87:6 	Phoenix (DIJEYO ) 	1131
1:117:10 	Phoenix (DIJEYO ) 	1131
1:193:13 	Phoenix (Daniman(i) ) 	1140
1:193:15 	Phoenix (Daniman(i) ) 	1140
1:234:7 	Phoenix (cyclops ) 	934
1:244:6 	Phoenix (SoDa(i) ) 	1023
1:244:7 M 	Phoenix (SoDa(i) ) 	1023
1:244:15 	Phoenix (SoDa(i) ) 	1023
1:307:4 	Phoenix (monfabramar ) 	449
1:329:7 	Phoenix (Profeshor(i) ) 	621
1:347:7 	Phoenix (Profeshor(i) ) 	621
1:390:8 	Phoenix (cyclops ) 	934
1:393:7 	Phoenix (madnux ) 	701
1:395:6 	Phoenix (dormicum ) 	1071
1:398:11 	Phoenix (gparedes ) 	383
1:428:7 	Phoenix (HGentatsu ) 	684
1:433:9 	Phoenix (cyclops ) 	934
1:460:6 	Phoenix (DrOsS ) 	1026
1:465:5 M 	Phoenix (gparedes ) 	383
1:467:6 M 	Phoenix (juliuss ) 	729
1:475:6 M 	Phoenix (dormicum ) 	1071
1:483:11 M 	Phoenix (IRONHIDE ) 	716
1:497:6 	Phoenix (HGentatsu ) 	684
2:2:4 	Phoenix (DIJEYO ) 	1131
2:40:9 	Phoenix (AnIhC ) 	867
2:50:6 	Phoenix (AnIhC ) 	867
2:50:12 	Phoenix (AnIhC ) 	867
2:52:6 	Phoenix (AnIhC ) 	867
2:53:9 	Phoenix (AnIhC ) 	867
2:73:7 	Phoenix (AnIhC ) 	867
2:93:6 M 	Phoenix (kakaroto ) 	358
2:98:6 M 	Phoenix (juliuss ) 	727
2:107:9 	Phoenix (AnIhC ) 	867
2:118:8 M 	Phoenix (dormicum ) 	1069
2:122:14 	Phoenix (dormicum ) 	1069
2:133:5 	Phoenix (DDuke ) 	559
2:139:5 	Phoenix (kakaroto ) 	358
2:145:6 	Phoenix (gparedes ) 	384
2:148:4 	Phoenix (AxL ) 	373
2:148:5 	Phoenix (HGentatsu ) 	682
2:235:6 	Phoenix (kakaroto ) 	358
2:235:8 M 	Phoenix (Daniman(i) ) 	1138
2:236:13 	Phoenix (Daniman(i) ) 	1138
2:236:14 M 	Phoenix (Daniman(i) ) 	1138
2:236:15 	Phoenix (Daniman(i) ) 	1138
2:241:4 M 	Phoenix (kakaroto ) 	358
2:242:6 	Phoenix (gparedes ) 	384
2:260:4 	Phoenix (Profeshor(i) ) 	620
2:279:10 	Phoenix (DDuke ) 	559
2:284:5 	Phoenix (DDuke ) 	559
2:305:8 	Phoenix (DDuke ) 	559
2:309:6 	Phoenix (Machuchin ) 	1141
2:316:7 	Phoenix (Machuchin ) 	1141
2:328:5 M 	Phoenix (DDuke ) 	559
2:329:7 	Phoenix (AnIhC ) 	867
2:331:13 M 	Phoenix (butcher ) 	477
2:338:5 	Phoenix (Profeshor(i) ) 	620
2:340:7 	Phoenix (butcher ) 	477
2:350:7 M 	Phoenix (butcher ) 	477
2:356:14 	Phoenix (butcher ) 	477
2:358:9 	Phoenix (butcher ) 	477
2:359:10 M 	Phoenix (butcher ) 	477
2:360:6 	Phoenix (DrOsS ) 	1024
2:377:4 	Phoenix (SoDa(i) ) 	1022
2:377:6 	Phoenix (SoDa(i) ) 	1022
2:382:4 M 	Phoenix (AxL ) 	373
2:382:5 	Phoenix (Profeshor(i) ) 	620
2:382:6 	Phoenix (AxL ) 	373
2:382:7 	Phoenix (Profeshor(i) ) 	620
2:382:8 	Phoenix (Viejo Lucho ) 	674
2:382:12 	Phoenix (Profeshor(i) ) 	620
2:383:6 	Phoenix (Profeshor(i) ) 	620
2:384:4 M 	Phoenix (AxL ) 	373
2:387:4 	Phoenix (Profeshor(i) ) 	620
2:392:5 	Phoenix (Viejo Lucho ) 	674
2:434:5 	Phoenix (Machuchin ) 	1141
2:446:7 	Phoenix (SoDa(i) ) 	1022
2:452:4 	Phoenix (AxL ) 	373
2:452:9 M 	Phoenix (AxL ) 	373
2:452:11 M 	Phoenix (IRONHIDE ) 	713
2:453:9 	Phoenix (gparedes ) 	384
2:455:5 	Phoenix (juliuss ) 	727
3:35:4 	Phoenix (cybermaster7 ) 	929
3:39:7 M 	Phoenix (Viejo Lucho ) 	673
3:43:4 	Phoenix (cybermaster7 ) 	931
3:126:9 	Phoenix (felipe ) 	560
3:131:6 	Phoenix (Viejo Lucho ) 	673
3:147:14 	Phoenix (Viejo Lucho ) 	673
3:151:13 M 	Phoenix (Viejo Lucho ) 	673
3:151:15 	Phoenix (Viejo Lucho ) 	673
3:153:5 	Phoenix (Viejo Lucho ) 	673
3:154:6 	Phoenix (godo ) 	840
3:173:9 M 	Phoenix (Machuchin ) 	1138
3:177:6 	Phoenix (kakaroto ) 	357
3:178:15 	Phoenix (Machuchin ) 	1138
3:183:13 	Phoenix (Andy9149 ) 	1009
3:188:4 	Phoenix (gparedes ) 	383
3:207:5 	Phoenix (Andy9149 ) 	1009
3:207:9 M 	Phoenix (Logan ) 	630
3:213:5 	Phoenix (Logan ) 	630
3:222:6 	Phoenix (Logan ) 	630
3:237:6 	Phoenix (gparedes ) 	383
3:261:7 	Phoenix (kakaroto ) 	357
3:262:6 	Phoenix (destroyer1 ) 	906
3:332:4 	Phoenix (godo ) 	840
3:336:4 M 	Phoenix (Andy9149 ) 	1009
3:337:8 M 	Phoenix (DDuke ) 	558
3:351:6 	Phoenix (Andy9149 ) 	1009
3:359:9 M 	Phoenix (kakaroto ) 	357
3:359:11 	Phoenix (IRONHIDE ) 	713
3:360:5 	Phoenix (kakaroto ) 	357
3:364:5 	Phoenix (cybermaster7 ) 	929
3:364:9 M 	Phoenix (AxL ) 	372
3:369:7 	Phoenix (SoDa(i) ) 	1021
3:383:7 M 	Phoenix (DIJEYO ) 	1136
3:399:6 	Phoenix (SoDa(i) ) 	1021
3:421:5 	Phoenix (cyclops ) 	935
3:447:6 	Phoenix (DIJEYO ) 	1136
3:463:9 M 	Phoenix (juliuss ) 	726
3:476:5 M 	Phoenix (butcher ) 	476
3:486:6 M 	Phoenix (cyclops ) 	934
3:493:8 	Phoenix (butcher ) 	476
4:7:7 	Phoenix (Dealer ) 	579
4:12:5 	Phoenix (Dealer ) 	579
4:12:12 M 	Phoenix (Dealer ) 	579
4:15:8 M 	Phoenix (Dealer ) 	590
4:16:6 	Phoenix (Dealer ) 	590
4:19:6 	Phoenix (DIJEYO ) 	1130
4:25:5 	Phoenix (Dealer ) 	579
4:26:12 	Phoenix (IRONHIDE ) 	713
4:29:6 	Phoenix (Logan ) 	626
4:30:6 M 	Phoenix (kakaroto ) 	355
4:33:6 	Phoenix (gparedes ) 	384
4:38:5 	Phoenix (greenmask ) 	1093
4:43:5 	Phoenix (Machuchin ) 	1138
4:43:6 	Phoenix (DrOsS ) 	1017
4:44:8 	Phoenix (Machuchin ) 	1149
4:46:12 	Phoenix (Andy9149(i) ) 	1018
4:51:11 	Phoenix (DrOsS ) 	1037
4:53:5 M 	Phoenix (AxL ) 	373
4:53:7 	Phoenix (Machuchin ) 	1149
4:54:8 	Phoenix (destroyer1 ) 	919
4:55:14 	Phoenix (dormicum ) 	1069
4:57:6 	Phoenix (dormicum ) 	1069
4:57:9 M 	Phoenix (Orion ) 	903
4:60:8 	Phoenix (madnux ) 	702
4:64:6 	Phoenix (greenmask ) 	1093
4:65:6 M 	Phoenix (gparedes ) 	384
4:66:5 	Phoenix (juliuss ) 	735
4:66:13 	Phoenix (HGentatsu ) 	688
4:71:8 	Phoenix (HGentatsu ) 	681
4:76:8 M 	Phoenix (juliuss ) 	735
4:78:6 M 	Phoenix (Andy9149(i) ) 	1018
4:78:7 	Phoenix (Logan ) 	626
4:80:5 	Phoenix (madnux ) 	702
4:84:5 M 	Phoenix (Logan ) 	626
4:88:5 	Phoenix (destroyer1 ) 	906
4:89:7 M 	Phoenix (Logan ) 	630
4:97:6 M 	Phoenix (felipe ) 	543
4:149:5 	Phoenix (cybermaster7 ) 	930
4:150:5 	Phoenix (cybermaster7 ) 	930
4:190:7 M 	Phoenix (felipe ) 	543
4:190:13 	Phoenix (IRONHIDE ) 	725
4:199:5 M 	Phoenix (destroyer1 ) 	919
4:235:7 	Phoenix (Andy9149(i) ) 	1018
4:254:4 	Phoenix (godo ) 	844
4:265:6 	Phoenix (DDuke ) 	576
4:289:5 	Phoenix (godo ) 	844
4:324:5 	Phoenix (destroyer1 ) 	919
4:362:4 	Phoenix (Orion ) 	911
4:362:5 	Phoenix (Orion ) 	911
4:362:6 	Phoenix (Orion ) 	911
4:394:5 	Phoenix (madnux ) 	702
4:394:6 M 	Phoenix (madnux ) 	702
4:399:5 	Phoenix (juliuss ) 	735
4:410:6 M 	Phoenix (DDuke ) 	576
4:414:6 	Phoenix (SoDa(i) ) 	1023
4:414:8 M 	Phoenix (godo ) 	844
4:426:5 	Phoenix (cyclops ) 	934
4:448:10 	Phoenix (godo ) 	844
4:449:7 	Phoenix (Viejo Lucho ) 	676
4:475:7 	Phoenix (cyclops ) 	934
4:476:6 	Phoenix (cyclops ) 	934
4:479:5 	Phoenix (cyclops ) 	934
5:4:5 	Phoenix (godo ) 	844
5:4:7 	Phoenix (monfabramar ) 	449
5:9:6 	Phoenix (godo ) 	844
5:10:9 	Phoenix (Machuchin ) 	1147
5:12:6 M 	Phoenix (Dealer ) 	590
5:23:7 M 	Phoenix (monfabramar ) 	451
5:27:6 	Phoenix (monfabramar ) 	451
5:27:7 	Phoenix (monfabramar ) 	451
5:33:5 	Phoenix (Andy9149(i) ) 	1018
5:34:4 	Phoenix (godo ) 	844
5:35:9 	Phoenix (monfabramar ) 	451
5:53:6 	Phoenix (destroyer1 ) 	918
5:90:5 	Phoenix (Logan ) 	628
5:108:4 	Phoenix (Logan ) 	628
5:119:4 	Phoenix (IRONHIDE ) 	717
5:120:4 	Phoenix (felipe ) 	543
5:120:6 	Phoenix (AxL ) 	373
5:122:7 M 	Phoenix (DDuke ) 	575
5:122:8 	Phoenix (AnIhC ) 	870
5:154:4 	Phoenix (felipe ) 	543
5:158:5 M 	Phoenix (DIJEYO ) 	1129
5:178:6 	Phoenix (felipe ) 	543
5:264:4 	Phoenix (greenmask ) 	1093
5:264:6 	Phoenix (greenmask ) 	1093
5:301:5 	Phoenix (felipe ) 	543
5:351:5 	Phoenix (IRONHIDE ) 	717
5:351:7 	Phoenix (DrOsS ) 	1038
5:353:5 	Phoenix (DrOsS ) 	1038
5:393:7 	Phoenix (madnux ) 	701
5:398:6 	Phoenix (felipe ) 	543
5:431:5 	Phoenix (butcher ) 	480
6:1:4 	Phoenix (Orion ) 	913
6:22:7 	Phoenix (greenmask ) 	1093
6:22:8 	Phoenix (greenmask ) 	1093
6:27:6 M 	Phoenix (DrOsS ) 	1038
6:32:6 	Phoenix (greenmask ) 	1087
6:32:7 	Phoenix (greenmask ) 	1087
6:128:6 M 	Phoenix (dormicum ) 	1073
6:151:6 	Phoenix (dormicum ) 	1073
6:236:4 M 	Phoenix (monfabramar ) 	451
6:242:5 	Phoenix (monfabramar ) 	451
6:242:6 	Phoenix (monfabramar ) 	451
6:282:8 	Phoenix (IRONHIDE ) 	720
6:307:4 	Phoenix (destroyer1 ) 	919
6:310:5 	Phoenix (destroyer1 ) 	919
6:397:5 	Phoenix (destroyer1 ) 	919
6:496:1 	Phoenix (madnux ) 	703
6:496:5 	Phoenix (madnux ) 	703
7:472:5 	Phoenix (DrOsS ) 	1033
7:472:6 	Phoenix (DrOsS ) 	1033
7:472:8 	Phoenix (IRONHIDE ) 	722
7:496:5 	Phoenix (madnux ) 	703
8:80:4 	Phoenix (Orion ) 	914
8:88:6 M 	Phoenix (juliuss ) 	731
8:96:4 	Phoenix (Orion ) 	914
9:88:4 	Phoenix (HGentatsu ) 	685
9:88:5 M 	Phoenix (HGentatsu ) 	685
9:88:6 M 	Phoenix (HGentatsu ) 	685
9:89:4 	Phoenix (DIJEYO ) 	1136
9:90:5 	Phoenix (HGentatsu ) 	685
9:285:4 M 	Phoenix (Orion ) 	913
9:308:4 	Phoenix (Orion ) 	913

 

How can i replace every space sections by 1 space?

Link to comment
Share on other sites

That will only replace the first set of double spaces, to replace all of them you need a loop (if you're using str_replace):

<?php
$str = '1:3:4            Phoenix  (cybermaster7 )      932';
echo '<pre>' . str_replace(' ','.',$str) . '</pre>'; // before
while (strpos($str,'  ') !== false) 
     $str = str_replace('  ',' ',$str);
echo '<pre>' . str_replace(' ','.',$str) . '</pre>'; // shows that the replace worked
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.