Martin Petercak
Martin Petercak

Reputation: 833

Join two binary strings

I am receiving binary data with socket_recv function. Is there some way in php to merge them into one so I can still work with them as with binary strings?

Upvotes: 3

Views: 3841

Answers (1)

phihag
phihag

Reputation: 287885

You can simply concatenate arbitrary strings with the . operator:

<?php
$s = "a\0b" . "c\0d";
var_export($s); // outputs  'a' . "\0" . 'bc' . "\0" . 'd'

Upvotes: 6

Related Questions