11
mawi27
Re: Drop down menu with unserlize function ?
  • 2008/3/10 15:00

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Got it!

$countries 'a:101:{s:13:"new_york_area";s:18:"002) New York Area";s:15:"other_place_usa";s:23:"003) Other place in USA";s:5:"italy";s:10:"004) Italy";s:11:"afghanistan";s:16:"006) Afghanistan";s:7:"albania";s:12:"007) Albania";s:7:"algeria";s:12:"008) Algeria";s:9:"argentina";s:14:"009) Argentina";s:9:"australia";s:14:"010) Australia";s:7:"austria";s:12:"011) Austria";s:15:"select_location";s:22:"001) Select a Location";s:7:"nothing";s:15:"005) ----------";s:7:"bahamas";s:12:"012) Bahamas";s:10:"bangladesh";s:15:"013) Bangladesh";s:7:"belgium";s:12:"014) Belgium";s:7:"bolivia";s:12:"015) Bolivia";s:18:"bosnia_herzegowina";s:27:"016) Bosnia and Herzegowina";s:6:"brazil";s:11:"017) Brazil";s:8:"bulgaria";s:13:"018) Bulgaria";s:6:"canada";s:11:"019) Canada";s:10:"cape_verde";s:15:"020) Cape Verde";s:5:"chile";s:10:"021) Chile";s:5:"china";s:10:"022) China";s:8:"colombia";s:13:"023) Colombia";s:5:"congo";s:10:"024) Congo";s:10:"costa_rica";s:15:"025) Costa Rica";s:7:"croatia";s:12:"026) Croatia";s:4:"cuba";s:9:"027) Cuba";s:14:"czech_republic";s:19:"028) Czech Republic";s:18:"dominican_republic";s:23:"029) Dominican Republic";s:5:"egypt";s:10:"030) Egypt";s:7:"estonia";s:12:"031) Estonia";s:4:"fiji";s:9:"032) Fiji";s:7:"finland";s:12:"033) Finland";s:6:"france";s:11:"034) France";s:7:"georgia";s:12:"035) Georgia";s:7:"germany";s:12:"036) Germany";s:5:"ghana";s:10:"037) Ghana";s:6:"greece";s:11:"038) Greece";s:9:"greenland";s:14:"039) Greenland";s:9:"guatemala";s:14:"040) Guatemala";s:6:"guinea";s:11:"041) Guinea";s:5:"haiti";s:10:"042) Haiti";s:9:"hong_kong";s:14:"043) Hong Kong";s:7:"hungary";s:12:"044) Hungary";s:7:"iceland";s:12:"045) Iceland";s:5:"india";s:10:"046) India";s:9:"indonesia";s:14:"047) Indonesia";s:4:"iran";s:9:"048) Iran";s:4:"iraq";s:9:"049) Iraq";s:7:"ireland";s:12:"050) Ireland";s:6:"israel";s:11:"051) Israel";s:7:"jamaica";s:12:"052) Jamaica";s:5:"japan";s:10:"053) Japan";s:6:"jordan";s:11:"054) Jordan";s:5:"kenya";s:10:"055) Kenya";s:5:"korea";s:10:"056) Korea";s:6:"kuwait";s:11:"057) Kuwait";s:9:"lithuania";s:14:"058) Lithuania";s:10:"madagascar";s:15:"059) Madagascar";s:8:"malaysia";s:13:"060) Malaysia";s:8:"maldives";s:13:"061) Maldives";s:5:"malta";s:10:"062) Malta";s:9:"mauritius";s:14:"063) Mauritius";s:6:"mexico";s:11:"064) Mexico";s:6:"monaco";s:11:"065) Monaco";s:10:"mozambique";s:15:"066) Mozambique";s:5:"nepal";s:10:"067) Nepal";s:11:"netherlands";s:16:"068) Netherlands";s:11:"new_zealand";s:16:"069) New Zealand";s:7:"nigeria";s:12:"070) Nigeria";s:8:"pakistan";s:13:"071) Pakistan";s:6:"panama";s:11:"072) Panama";s:8:"paraguay";s:13:"073) Paraguay";s:4:"peru";s:9:"074) Peru";s:6:"poland";s:11:"075) Poland";s:8:"portugal";s:13:"076) Portugal";s:7:"romania";s:12:"077) Romania";s:18:"russian_federation";s:23:"078) Russian Federation";s:12:"saudi_arabia";s:17:"079) Saudi Arabia";s:9:"singapore";s:14:"080) Singapore";s:8:"slovakia";s:13:"081) Slovakia";s:8:"slovenia";s:13:"082) Slovenia";s:7:"somalia";s:12:"083) Somalia";s:12:"south_africa";s:17:"084) South Africa";s:5:"spain";s:10:"085) Spain";s:6:"sweden";s:11:"086) Sweden";s:11:"switzerland";s:16:"087) Switzerland";s:6:"taiwan";s:11:"088) Taiwan";s:8:"thailand";s:13:"089) Thailand";s:7:"tunisia";s:12:"090) Tunisia";s:6:"turkey";s:11:"091) Turkey";s:7:"ukraine";s:12:"092) Ukraine";s:19:"united_arabemirates";s:24:"093) United ArabEmirates";s:14:"united_kingdom";s:19:"094) United Kingdom";s:7:"uruguay";s:12:"095) Uruguay";s:9:"venezuela";s:14:"096) Venezuela";s:14:"virgin_islands";s:19:"097) Virgin Islands";s:10:"yugoslavia";s:15:"098) Yugoslavia";s:5:"zaire";s:10:"099) Zaire";s:6:"zambia";s:11:"100) Zambia";s:8:"zimbabwe";s:13:"101) Zimbabwe";}';

$token strtok($countries,":;");
$q=1;
echo
"";

while (
$token) {

 if (
substr($token,4,1) == ")") {
 
$country_id substr($token,1,3);
 
$country_name substr($token,5,-1);
 echo
".$country_id.">$country_namen";
 }

    
$token strtok(":;");
    
$q++;

}
echo
"";


I have tested it - it works

Best regards,
Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

12
slyss
Re: Drop down menu with unserlize function ?
  • 2008/3/10 15:18

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


is nearly right!!!!

i need for eg.:

$country_id = 'new_york_area';
$country_name = 'New York Area';

....

$country_id = 'other_place_usa';
$country_name = 'Other place in USA';

so, not id but string name ... is possible?

thanks a lot for your time
[size=x-large]2008 Xoops Book[/size]

13
mawi27
Re: Drop down menu with unserlize function ?
  • 2008/3/10 15:59

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1




$countries 'a:101:{s:13:"new_york_area";s:18:"002) New York Area";s:15:"other_place_usa";s:23:"003) Other place in USA";s:5:"italy";s:10:"004) Italy";s:11:"afghanistan";s:16:"006) Afghanistan";s:7:"albania";s:12:"007) Albania";s:7:"algeria";s:12:"008) Algeria";s:9:"argentina";s:14:"009) Argentina";s:9:"australia";s:14:"010) Australia";s:7:"austria";s:12:"011) Austria";s:15:"select_location";s:22:"001) Select a Location";s:7:"nothing";s:15:"005) ----------";s:7:"bahamas";s:12:"012) Bahamas";s:10:"bangladesh";s:15:"013) Bangladesh";s:7:"belgium";s:12:"014) Belgium";s:7:"bolivia";s:12:"015) Bolivia";s:18:"bosnia_herzegowina";s:27:"016) Bosnia and Herzegowina";s:6:"brazil";s:11:"017) Brazil";s:8:"bulgaria";s:13:"018) Bulgaria";s:6:"canada";s:11:"019) Canada";s:10:"cape_verde";s:15:"020) Cape Verde";s:5:"chile";s:10:"021) Chile";s:5:"china";s:10:"022) China";s:8:"colombia";s:13:"023) Colombia";s:5:"congo";s:10:"024) Congo";s:10:"costa_rica";s:15:"025) Costa Rica";s:7:"croatia";s:12:"026) Croatia";s:4:"cuba";s:9:"027) Cuba";s:14:"czech_republic";s:19:"028) Czech Republic";s:18:"dominican_republic";s:23:"029) Dominican Republic";s:5:"egypt";s:10:"030) Egypt";s:7:"estonia";s:12:"031) Estonia";s:4:"fiji";s:9:"032) Fiji";s:7:"finland";s:12:"033) Finland";s:6:"france";s:11:"034) France";s:7:"georgia";s:12:"035) Georgia";s:7:"germany";s:12:"036) Germany";s:5:"ghana";s:10:"037) Ghana";s:6:"greece";s:11:"038) Greece";s:9:"greenland";s:14:"039) Greenland";s:9:"guatemala";s:14:"040) Guatemala";s:6:"guinea";s:11:"041) Guinea";s:5:"haiti";s:10:"042) Haiti";s:9:"hong_kong";s:14:"043) Hong Kong";s:7:"hungary";s:12:"044) Hungary";s:7:"iceland";s:12:"045) Iceland";s:5:"india";s:10:"046) India";s:9:"indonesia";s:14:"047) Indonesia";s:4:"iran";s:9:"048) Iran";s:4:"iraq";s:9:"049) Iraq";s:7:"ireland";s:12:"050) Ireland";s:6:"israel";s:11:"051) Israel";s:7:"jamaica";s:12:"052) Jamaica";s:5:"japan";s:10:"053) Japan";s:6:"jordan";s:11:"054) Jordan";s:5:"kenya";s:10:"055) Kenya";s:5:"korea";s:10:"056) Korea";s:6:"kuwait";s:11:"057) Kuwait";s:9:"lithuania";s:14:"058) Lithuania";s:10:"madagascar";s:15:"059) Madagascar";s:8:"malaysia";s:13:"060) Malaysia";s:8:"maldives";s:13:"061) Maldives";s:5:"malta";s:10:"062) Malta";s:9:"mauritius";s:14:"063) Mauritius";s:6:"mexico";s:11:"064) Mexico";s:6:"monaco";s:11:"065) Monaco";s:10:"mozambique";s:15:"066) Mozambique";s:5:"nepal";s:10:"067) Nepal";s:11:"netherlands";s:16:"068) Netherlands";s:11:"new_zealand";s:16:"069) New Zealand";s:7:"nigeria";s:12:"070) Nigeria";s:8:"pakistan";s:13:"071) Pakistan";s:6:"panama";s:11:"072) Panama";s:8:"paraguay";s:13:"073) Paraguay";s:4:"peru";s:9:"074) Peru";s:6:"poland";s:11:"075) Poland";s:8:"portugal";s:13:"076) Portugal";s:7:"romania";s:12:"077) Romania";s:18:"russian_federation";s:23:"078) Russian Federation";s:12:"saudi_arabia";s:17:"079) Saudi Arabia";s:9:"singapore";s:14:"080) Singapore";s:8:"slovakia";s:13:"081) Slovakia";s:8:"slovenia";s:13:"082) Slovenia";s:7:"somalia";s:12:"083) Somalia";s:12:"south_africa";s:17:"084) South Africa";s:5:"spain";s:10:"085) Spain";s:6:"sweden";s:11:"086) Sweden";s:11:"switzerland";s:16:"087) Switzerland";s:6:"taiwan";s:11:"088) Taiwan";s:8:"thailand";s:13:"089) Thailand";s:7:"tunisia";s:12:"090) Tunisia";s:6:"turkey";s:11:"091) Turkey";s:7:"ukraine";s:12:"092) Ukraine";s:19:"united_arabemirates";s:24:"093) United ArabEmirates";s:14:"united_kingdom";s:19:"094) United Kingdom";s:7:"uruguay";s:12:"095) Uruguay";s:9:"venezuela";s:14:"096) Venezuela";s:14:"virgin_islands";s:19:"097) Virgin Islands";s:10:"yugoslavia";s:15:"098) Yugoslavia";s:5:"zaire";s:10:"099) Zaire";s:6:"zambia";s:11:"100) Zambia";s:8:"zimbabwe";s:13:"101) Zimbabwe";}';

$token strtok($countries,":;");
$q=1;

while (
$token) {

    if (
substr($token,0,1) == """) {
        
        if (substr(
$token,4,1) != ")") {
            
$country[$q]['id'] = substr($token,1,-1);
        } else {
            
$country[$q]['name'] = substr($token,5,-1);
            
$q++;
        }
    }
    
$token = strtok(":;");
}

echo"
<select name='countries'>";
foreach (array_keys(
$country) as $j) {
 
$country_id = $country[$j]['id'];
 
$country_name = $country[$j]['name'];
 echo"
<option value=".$country_id.">$country_nameoption>n";
}    
echo"
select>";


Now I need a
Have Fun,
Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

14
slyss
Re: Drop down menu with unserlize function ?
  • 2008/3/10 16:07

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


it dosn't work

what kind of beer i can ship to you ?
[size=x-large]2008 Xoops Book[/size]

15
mawi27
Re: Drop down menu with unserlize function ?
  • 2008/3/10 16:17

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


what you mean, It doesn't work??

Have a look here
Full code for the demo is:


$countries 
'a:101:{s:13:"new_york_area";s:18:"002) New York Area";s:15:"other_place_usa";s:23:"003) Other place in USA";s:5:"italy";s:10:"004) Italy";s:11:"afghanistan";s:16:"006) Afghanistan";s:7:"albania";s:12:"007) Albania";s:7:"algeria";s:12:"008) Algeria";s:9:"argentina";s:14:"009) Argentina";s:9:"australia";s:14:"010) Australia";s:7:"austria";s:12:"011) Austria";s:15:"select_location";s:22:"001) Select a Location";s:7:"nothing";s:15:"005) ----------";s:7:"bahamas";s:12:"012) Bahamas";s:10:"bangladesh";s:15:"013) Bangladesh";s:7:"belgium";s:12:"014) Belgium";s:7:"bolivia";s:12:"015) Bolivia";s:18:"bosnia_herzegowina";s:27:"016) Bosnia and Herzegowina";s:6:"brazil";s:11:"017) Brazil";s:8:"bulgaria";s:13:"018) Bulgaria";s:6:"canada";s:11:"019) Canada";s:10:"cape_verde";s:15:"020) Cape Verde";s:5:"chile";s:10:"021) Chile";s:5:"china";s:10:"022) China";s:8:"colombia";s:13:"023) Colombia";s:5:"congo";s:10:"024) Congo";s:10:"costa_rica";s:15:"025) Costa Rica";s:7:"croatia";s:12:"026) Croatia";s:4:"cuba";s:9:"027) Cuba";s:14:"czech_republic";s:19:"028) Czech Republic";s:18:"dominican_republic";s:23:"029) Dominican Republic";s:5:"egypt";s:10:"030) Egypt";s:7:"estonia";s:12:"031) Estonia";s:4:"fiji";s:9:"032) Fiji";s:7:"finland";s:12:"033) Finland";s:6:"france";s:11:"034) France";s:7:"georgia";s:12:"035) Georgia";s:7:"germany";s:12:"036) Germany";s:5:"ghana";s:10:"037) Ghana";s:6:"greece";s:11:"038) Greece";s:9:"greenland";s:14:"039) Greenland";s:9:"guatemala";s:14:"040) Guatemala";s:6:"guinea";s:11:"041) Guinea";s:5:"haiti";s:10:"042) Haiti";s:9:"hong_kong";s:14:"043) Hong Kong";s:7:"hungary";s:12:"044) Hungary";s:7:"iceland";s:12:"045) Iceland";s:5:"india";s:10:"046) India";s:9:"indonesia";s:14:"047) Indonesia";s:4:"iran";s:9:"048) Iran";s:4:"iraq";s:9:"049) Iraq";s:7:"ireland";s:12:"050) Ireland";s:6:"israel";s:11:"051) Israel";s:7:"jamaica";s:12:"052) Jamaica";s:5:"japan";s:10:"053) Japan";s:6:"jordan";s:11:"054) Jordan";s:5:"kenya";s:10:"055) Kenya";s:5:"korea";s:10:"056) Korea";s:6:"kuwait";s:11:"057) Kuwait";s:9:"lithuania";s:14:"058) Lithuania";s:10:"madagascar";s:15:"059) Madagascar";s:8:"malaysia";s:13:"060) Malaysia";s:8:"maldives";s:13:"061) Maldives";s:5:"malta";s:10:"062) Malta";s:9:"mauritius";s:14:"063) Mauritius";s:6:"mexico";s:11:"064) Mexico";s:6:"monaco";s:11:"065) Monaco";s:10:"mozambique";s:15:"066) Mozambique";s:5:"nepal";s:10:"067) Nepal";s:11:"netherlands";s:16:"068) Netherlands";s:11:"new_zealand";s:16:"069) New Zealand";s:7:"nigeria";s:12:"070) Nigeria";s:8:"pakistan";s:13:"071) Pakistan";s:6:"panama";s:11:"072) Panama";s:8:"paraguay";s:13:"073) Paraguay";s:4:"peru";s:9:"074) Peru";s:6:"poland";s:11:"075) Poland";s:8:"portugal";s:13:"076) Portugal";s:7:"romania";s:12:"077) Romania";s:18:"russian_federation";s:23:"078) Russian Federation";s:12:"saudi_arabia";s:17:"079) Saudi Arabia";s:9:"singapore";s:14:"080) Singapore";s:8:"slovakia";s:13:"081) Slovakia";s:8:"slovenia";s:13:"082) Slovenia";s:7:"somalia";s:12:"083) Somalia";s:12:"south_africa";s:17:"084) South Africa";s:5:"spain";s:10:"085) Spain";s:6:"sweden";s:11:"086) Sweden";s:11:"switzerland";s:16:"087) Switzerland";s:6:"taiwan";s:11:"088) Taiwan";s:8:"thailand";s:13:"089) Thailand";s:7:"tunisia";s:12:"090) Tunisia";s:6:"turkey";s:11:"091) Turkey";s:7:"ukraine";s:12:"092) Ukraine";s:19:"united_arabemirates";s:24:"093) United ArabEmirates";s:14:"united_kingdom";s:19:"094) United Kingdom";s:7:"uruguay";s:12:"095) Uruguay";s:9:"venezuela";s:14:"096) Venezuela";s:14:"virgin_islands";s:19:"097) Virgin Islands";s:10:"yugoslavia";s:15:"098) Yugoslavia";s:5:"zaire";s:10:"099) Zaire";s:6:"zambia";s:11:"100) Zambia";s:8:"zimbabwe";s:13:"101) Zimbabwe";}';

$token strtok($countries,":;");
$q=1;

while (
$token) {

    if (
substr($token,0,1) == """) {
        
        if (substr(
$token,4,1) != ")") {
            
$country[$q]['id'] = substr($token,1,-1);
        } else {
            
$country[$q]['name'] = substr($token,5,-1);
            
$q++;
        }
    }
    
$token = strtok(":;");
}

echo"
<select name='countries'>";
foreach (array_keys(
$country) as $j) {
 
$country_id = $country[$j]['id'];
 
$country_name = $country[$j]['name'];
 echo"
<option value=".$country_id.">$country_nameoption>n";
}    
echo"
select>";

?>


Do you get any error messages?

Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

16
slyss
Re: Drop down menu with unserlize function ?
  • 2008/3/10 16:27

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


now is ok...

i have change:

if (substr($token,0,1) == """)


with:

if (substr($token,0,1) == '"')


thanks a lot for your time...

you are a great developer...

thanks a lot...
[size=x-large]2008 Xoops Book[/size]

17
mawi27
Re: Drop down menu with unserlize function ?
  • 2008/3/10 17:11

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


That was the problem with the escape signs again. In my original it is: "\""

I would like a really cold Moretti now. Please drink one for me

Have Fun,
Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

18
slyss
Re: Drop down menu with unserlize function ?
  • 2008/3/10 21:48

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


[size=x-large]2008 Xoops Book[/size]

19
slyss
Re: Drop down menu with unserlize function ?
  • 2008/4/12 13:45

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


hi guys...

i have a little problem:

how i can make script work with this variable?:

$countries 'a:2:{s:5:"milan";s:6:"Milano";s:6:"naples";s:6:"Napoli";}';


thanks a lot
[size=x-large]2008 Xoops Book[/size]

20
slyss
Re: Drop down menu with unserlize function ?
  • 2008/4/14 11:40

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


anyone ?
[size=x-large]2008 Xoops Book[/size]

Login

Who's Online

433 user(s) are online (317 user(s) are browsing Support Forums)


Members: 0


Guests: 433


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits