2014-10-08 161 views
0

我一直希望得到一些想法/幫助與PHP。
我使用下面的代碼返回一個值,在我的情況下,它的值是十六進制的十進制數字612B。我需要翻轉2B和2B61。PHP分割結果

$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); 

謝謝。

編輯1:

其中

str_split($test, 2))); 

我不得不將其更改爲

str_split($test, 1))); 

而且我得到了正是我想要的。 感謝您的幫助。

+0

如果是字符串 - $ skillfound1 = substr($ skillfound1,2)。 substr($ skillfound1,0,2);'或'$ skillfound1 = preg_replace('/(\ w {2})(\ w {2})/','$ 2 $ 1',$ skillfound1);' – Cheery 2014-10-08 23:24:31

回答

1
$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);