Can anyone please help me regarding this issue, i tried alot regexp and substr too but im unable to figure it out. My requirement is to add | sign in string after 1, 28, 48, 62 and so on! im converting a text file into psv format for our crm, can anybody help me regarding this? Regards
$final = preg_replace("/^(.{0})/", "$1|", $line[0]);
this code is matching only one position per string, i want to replace to 6-10 specific columns, i tried this too but not working
$final = preg_replace("/^(.{0}{28}{48})/", "$1| $2| $3|", $line[0]);
but my solution in this expression if it works one more example input:
$string = "80293066640226135465 NRIC 011064608711 HAZRY BIN ABDULLAH 0138258856 LOT 7083,LORONG 6B1 JLN MATANG TAMAN MATANG JAYA 93050,KUCHING,SAR 93050 SAR ABO TAYANGAN HEBAT FOR VALUE PACK,ABO TAYANGAN HEBAT HD,AOTG + CATCH UPMALAY URB4929 1 2015090404/09/2015 04/11/2015 138.0000 BASIC FAMILY HD PACKAGE,HD SERVICES FOR VALUE PACK,RECORDING (XTV) FOR
"; desired output:
80293066|640226135465|NRIC|011064608711|HAZRY BIN ABDULLAH||0138258856||||$ $ $LOT 7083,LORONG 6B1 JLN MATANG$|TAMAN MATANG JAYA $93050$,KUCHING,SAR $SAR $||ABO TAYANGAN HEBAT FOR VALUE PACK,ABO TAYANGAN HEBAT HD,AOTG + CATCH UP|MALAY|URB4929||1|20150904|04/09/2015|04/11/2015|138.0000||BASIC FAMILY HD PACKAGE,HD SERVICES FOR VALUE PACK,RECORDING (XTV) FOR|||
so some fields will have | sign and some will have $.