note 75697 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 18:28:37 +0000 |
| Subject: | note 75697 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218678@lists.php.net to get a copy of this message | ||
Note Submitter: l0c4lh0st DOT nl AT gmail DOT com
----
how I can conwert
$string
'1, 2, 5, 6, 10, 13, 23'
from ENUM at mySQL to
$array
[0] -> false
[1] -> true
[2] -> true
[3] -> false
[4] -> false
[5] -> true
[6] -> true
[7] -> false
[8] -> false
[9] -> false
[10] -> true
[11] -> false
[12] -> false
[13] -> true
[14] -> false
[15] -> false
...
[23] -> true
<?php
function enum_to_array($psEnum)
{
$aReturn = array();
$aTemp = explode(', ', $psEnum);
for ($i = $aTemp[0]; $i <= $aTemp[count($aTemp)-1]; $i++)
{
$aReturn[$i] = in_array($i, $aTemp);
}
}
?>