Member Avatar
diafol

That's OK. I'll have a little play with the data and see what comes up. I get this with the code I supplied:

44797672146744781781414929/02/2012 16:43:30SMS0 ATE0 AT+CMGS=+447817814149 
Array
(
    [0] => 44797672146744781781414929/02/2012 16:43:30SMS0 ATE0 AT+CMGS=+447817814149 
    [1] => 447976721467447817814149
    [2] => 29/02/2012
    [3] => 16:43:30
    [4] =>  ATE0 AT+CMGS=+447817814149 
)
44797672147044781781414929/02/2012 16:47:06SMS0 bonjour
Array
(
    [0] => 44797672147044781781414929/02/2012 16:47:06SMS0 bonjour
    [1] => 447976721470447817814149
    [2] => 29/02/2012
    [3] => 16:47:06
    [4] =>  bonjour
)
44797672146744781781414929/02/2012 16:49:29SMS0
Array
(
    [0] => 44797672146744781781414929/02/2012 16:49:29SMS0
    [1] => 447976721467447817814149
    [2] => 29/02/2012
    [3] => 16:49:29
    [4] => 
)
Member Avatar
diafol

perhaps it's untrimmed - try this:

'/^(\d+)

to

'/(\d+)

i think i found out whats the problem is, its preg_match that is not working because its not sorting out anything i just double checked it by commenting out preg_match still get the same numbers. just viewed the source code so here is the format
output = 44797672146744781781414929/02/2012 16:43:30SMS0 ATE0 AT+CMGS=+447817814149

html format :

<messagerx><sourcemsisdn>447976721467</sourcemsisdn><destinationmsisdn>447817814149</destinationmsisdn><receivedtime>29/02/2012 16:43:30</receivedtime><bearer>SMS</bearer><messageref>0</messageref><message>
ATE0

AT+CMGS=+447817814149

hope the html format helps

Member Avatar
diafol

Wait a minute - where did all that xml come from? Was that always there? I thought that your peekmessage() method was stripping all those. Even if it is being stripped, there may be hidden characters e.g. '\n'.

So if the peekmessage isn't removing the tags, you could just use SimpleXML to get the data into an array or go overboard with a pregmatch.

i guess peek message did not remove all the xml tags

Member Avatar
diafol

either that or the carriage returns in the last match are causing the fail.