note 75697 added to function.str-split
| From: | l0c4lh0stDOTnlATgmailDOTcom at osu1 dot php dot net | Date: | Tue, 12 Jun 2007 12:28:27 +0000 |
| Subject: | note 75697 added to function.str-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127416@lists.php.net to get a copy of this message | ||
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);
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 77.248.151.33
----
Manual Page -- http://www.php.net/manual/en/function.str-split.php
Edit -- https://master.php.net/note/edit/75697
Del: integrated -- https://master.php.net/note/delete/75697/integrated
Del: useless -- https://master.php.net/note/delete/75697/useless
Del: bad code -- https://master.php.net/note/delete/75697/bad+code
Del: spam -- https://master.php.net/note/delete/75697/spam
Del: non-english -- https://master.php.net/note/delete/75697/non-english
Del: in docs -- https://master.php.net/note/delete/75697/in+docs
Del: other reasons-- https://master.php.net/note/delete/75697
Reject -- https://master.php.net/note/reject/75697
Search -- https://master.php.net/manage/user-notes.php