Convert GUID into Byte array using PHP?


I need to convert a system-generated GUID into a Byte[16] array and then convert those decimal values into a hex value string. Crazy, I know and I'm very open to a more efficient approach than the ones I've tried!

I've tried PHPs unpack() function on this GUID but can't seem to get the right format. I've tried c*, C* and all of the other possible formats.

Here's the GUID I'm starting with:


The Byte[16] array I'm trying to populate should look like this:

$bytearray = array(119,4,97,69,34,35,-108,101,-31,0,0,0,-110,-31,80,-48);

Once I get this $bytearray value, I can easily use PHPs dechex() function to convert each of these decimal values into their corresponding hex values. The end result of this conversion should look like this:

DEC: HEX 119: 77 4: 4 97: 61 69: 45 34: 22 35: 23 -108: 94 101: 65 -31: E1 0: 00 0: 00 0: 00 -110: 92 -31: E1 80: 50 -48: D0

Again, any suggestions are greatly appreciated.


I'm not sure I really get what you want… You want an array with the hex value of the ASCCI code of the chars within you ID, am I right?

$str = "dwRhRSIjlGXhAAAAkuFQ0A"; $bytes = array(); for($i=0,$l = strlen($str);$i<$l;$i++) { $bytes[] = dechex(ord($str[$i])); }


  • 基于Java+Selenium的WebUI自动化测试框架(九)-----基础页面类(BasePage)
  • How to get provider access token in Firebase functions?
  • ASP.NET MVC - How to detect if user is using a screen reader
  • RabbitMQ 六种工作模式
  • Swift: Error when trying to import UIKit
  • What is the difference between ui-view in angularjs and ion-nav-view in ionic
  • Delphi 'AND' evaluation with 2 conditions
  • Access our own AWS/RDS instance from cloudcontrol apps [closed]
  • How to save the request.referrer for facebook omniauth in Rails 4
  • How to maintain DatePicKer State After Rotate Screen
  • Spring boot 2.1.0 security change with kotlin data class?
  • Vue router and webpack - history mode config localhost
  • When is quoting necessary in prepared statements of pdo in PHP?
  • WSO2 ESB - Data Services Server Feature - How to use Data Sources to swap data source on fly
  • Java Regex Finding digits in a String
  • WCF Services with JSON, JSONP and SOAP End Points
  • How to get strings in parentheses into array with java
  • Replace Windows command FTP -s:E:\\FtpScript.txt with SFTP? [duplicate]
  • Why $.each() is slower than for loop in jquery?
  • -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
  • checkbox doesn't (check/uncheck) work inside bootstrap tab-pane
  • Get method parameters with specific annotation in aspect in scala using java reflection
  • Identify File Type in Java
  • Enable CORS on Tomcat 8.0.30
  • Map Annotation Disclosure Indicator - Xamarin.Form
  • How to get File path from pdfUri obtained from PDF chooser intent library, in onActivityResult call
  • how to add dashed border on highcharts “area” graph for every point
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • JavaMail connection problems [duplicate]
  • Stop an element moving with padding on hover
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • Background transfer download task failed when app was closed
  • ssh remote server login script
  • Firebase: How to read from external DB?
  • WPF custom control and direct content support
  • Create/delete users from text file using Bash script
  • Time Complexity of Fibonacci Algorithm [duplicate]
  • How to check if object is null in Java?