What can I do instead??

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

Tue Mar 05, 2013 6:13 am

I use the following to pull data from a string of characters.

Code: Select all

if ($s = stristr($string,"<QSO_DATE"))
	$values = $s, "<QSO_DATE:%d>%s ", $length,$qso_data['Date']);
	if ($values != 2)
	sscanf ($s, "<QSO_DATE:%d:%c>%s ", $length,$dummy,$qso_data['Date']);
The text usually looks like this:
<CALL:4>WM4Q <QSO_DATE:8:D>19870801 <TIME_ON:4>1806 <BAND:3>10M <MODE:3>SSB <RST_SENT:2>59 <QSL_SENT:1>Y <QSL_SENT_VIA:1> E<EOR>
<CALL:6>ON4AMT <QSO_DATE:8:D>19891209 <TIME_ON:4>1548 <BAND:3>10M <MODE:3>SSB<RST_SENT:2>59 <QSL_SENT:1>Y <QSL_SENT_VIA:1>E <EOR>
<CALL:6>IK3ORD <QSO_DATE:8:D>19901208 <TIME_ON:4>1339 <BAND:3>10M <MODE:3>SSB <RST_SENT:2>59 <QSL_SENT:1>Y <QSL_SENT_VIA:1> E<EOR>
Note the spaces separates the data.

But some of the text that needs to be processed comes in like this with no spaces in between data.

When data comes like that the routine above bombs out. what can I use in place of the sscanf ( that would let me separate out the data with either a space or no space?? I know some PHP but not a lot so if someone can explain what to use I would be appreciated..



Sat Mar 09, 2013 5:48 am

OK Here is what I have done but this does not seem to work for me for some reason.

I found a function that will extract between a start point and an end point.

Code: Select all

function extractString($start,$end,$total){
$total = stristr($total,$start);
$f2 = stristr($total,$end);
return substr($total,strlen($start),-strlen($f2));
and I am calling the function like this:

Code: Select all

If I set an echo at the top of the function everything is getting to the top of it. But does anyone see why it would not return anything back to the calling routine??


php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Sun Mar 10, 2013 6:30 am

store substr($total,strlen($start),-strlen($f2)); to a variable and echo it. Then you will know why that function is not returning anything.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests