explode an array based on a Carriage Return Line Feed
Posted: Mon Sep 20, 2010 10:26 am
Hi guys,
Is there a way to explode an array based on a Carriage Return Line Feed?
--reason below
I am running a MySQL query, which I then put into an Array. One of those MySQL fields is a MEDIUMTEXT field and contains a string of data that looks like:
Mesg Time: 04:55 Mesg Date: 13/09/2010
For: company support
From: John
Company: companyName
Phone: 01234 567 890
Message Taken By: user 1
ORD 3483 on 13/09/2010 at 04:54
Was Relayed To:-
(1)user 100,Mob: 07808 123456
Call Successfully Relayed
I then Explode this into another Array using the : as the divider.
I then explode this further on a line by line basis in order to leave me with the just the data I need, which I can then display in a table.
My problem comes at the line
07808 123456
Call Successfully Relayed
I want to be left with:
07808 123456
Call Successfully Relayed
That is fine. By using the word 'Call' as the divider I had:
07808 123456
Successfully relayed
close enough for my needs. but then I discovered some calls that look like:
07808 123456
No Answer
I thought, that's fine, I'll split it using " " (space) and then check
but it doesn't work as there isn't actually a space between the two parts, so what I end up with is:
07808
123456 No
Answer
When I checked using a hex editor, I found there is a 0D0A in there (carriage return Line feed), not a space. And that is what's causing the problem. Is there a a way to filter these?
Is there a way to explode an array based on a Carriage Return Line Feed?
--reason below
I am running a MySQL query, which I then put into an Array. One of those MySQL fields is a MEDIUMTEXT field and contains a string of data that looks like:
Mesg Time: 04:55 Mesg Date: 13/09/2010
For: company support
From: John
Company: companyName
Phone: 01234 567 890
Message Taken By: user 1
ORD 3483 on 13/09/2010 at 04:54
Was Relayed To:-
(1)user 100,Mob: 07808 123456
Call Successfully Relayed
I then Explode this into another Array using the : as the divider.
I then explode this further on a line by line basis in order to leave me with the just the data I need, which I can then display in a table.
My problem comes at the line
07808 123456
Call Successfully Relayed
I want to be left with:
07808 123456
Call Successfully Relayed
That is fine. By using the word 'Call' as the divider I had:
07808 123456
Successfully relayed
close enough for my needs. but then I discovered some calls that look like:
07808 123456
No Answer
I thought, that's fine, I'll split it using " " (space) and then check
Code: Select all
IF ($array[11][2] = "Call") {$result = $array[11][2].$array[11][3].$array[11][4]}; // Call Successfully relayed
ELSEIF {($array[11][2] = "No") {$result = $array[11][2].$array[11][3]}; // No Answer
07808
123456 No
Answer
When I checked using a hex editor, I found there is a 0D0A in there (carriage return Line feed), not a space. And that is what's causing the problem. Is there a a way to filter these?