Chris Tindal
Chris Tindal

Reputation: 7

PHP Splitting a result

I was hoping to get some ideas/help with php.
I use the following to return a value which in my case is 612B Hex decimal. I need to flip the 61 & 2B and make 2B61.

$skillsearch1 = odbc_exec($conn1,"select cast(cast(reverse(substring(strevent, 1, 1))as varbinary)as int) from USER_EVENT where strUserID='loneranger'");
$skillfound1 = odbc_result($skillsearch1,1);

Thanks.

EDIT 1:

where

 str_split($test, 2))); 

I just had to change it to

 str_split($test, 1))); 

And I got exactly what I wanted. Thanks for your help.

Upvotes: 0

Views: 45

Answers (1)

sectus
sectus

Reputation: 15464

$test = '1234';

$result = implode(                     // 3. join array to string
            array_reverse(             // 2. reverse order of this array
                str_split($test, 2))); // 1. convert string to array with two chars values

var_dump($result);

Upvotes: 1

Related Questions