str_split AND base_convert one field into 6 different fields

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed May 16, 2012 8:26 am

str_split AND base_convert one field into 6 different fields

Postby WhiteStacey » Wed May 16, 2012 8:34 am

I am very new to php. I love it. I really like the versatility of it, esp mixed with other web based languages.
I have only been working with php and my sql for a short while, so my knowledge of it is still limited.

What I'm required to do is take a colour hex code from one field, break it into individual characters, convert it from a base 16 to a base 10 and update 6 additional columns with the new numbers.

the first part is easy:

Code: Select all

$hexArray = str_split($formHEX);
      $hex1 = base_convert($hexArray[0], 16, 10);
      $hex2 = base_convert($hexArray[1], 16, 10);
      $hex3 = base_convert($hexArray[2], 16, 10);
      $hex4 = base_convert($hexArray[3], 16, 10);
      $hex5 = base_convert($hexArray[4], 16, 10);
      $hex6 = base_convert($hexArray[5], 16, 10);

its the dynamically updating every row base on it's initial value is the hard part.
ideas anyone?

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 5 guests