select string between characters

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
Reaction score
7
Location
CPT
Hi

Im having a really hard time with this one.

I'm using php on my server.

I am being sent data on a port on my server and I'm using fsockopen to get that info.

the info is being sent enclosed by two hex characters, so hex 02 to signal the beginning and hex 03 to signal the end.

So what I was doing was just stripping the hex out and inserting the string into the DB. I notice now that sometime they can send multiple stream of info in one shot, so hex02DATAhex03hex02DATAhex03

does anyone know a good method to select the data between the two hex values and store it in an array or something?

I am so stuck on this.
 
$data = split ( "/x03", $netdata );
foreach($data as $item){ $row = trim( $item, "/x02"); insert $row into table; }

Afaik split() is being deprecated and you should switch to preg_split() instead (it's also way way faster).

$data = preg_split("/\x03/",$netdata);
 
Afaik split() is being deprecated and you should switch to preg_split() instead (it's also way way faster).

Yeah you are right, split is being deprecated. We are going through our code base and strip them out where we find them.

Oh and @Light, you made me think of this :D
 
Does anyone here not have to use google when using regular expression? I can never remember the formats.

*does a turn around the fish pond*
 
Top
Sign up to the MyBroadband newsletter
X