Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
5 + 5 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
number is odd"; $country[$q]['id'] = substr($token,1,-1); } else { echo " -> number is even"; $country[$q-1]['name'] = substr($token,1,-1); } $q++; echo ""; } $token = strtok(';:'); } echo ""; echo""; foreach (array_keys($country) as $j) { $country_id = $country[$j]['id']; $country_name = $country[$j]['name']; echo"$country_namen"; } echo""; [/code] arrivederci, Marco[/quote]" />

Re: Drop down menu with unserlize function ?
by mawi27 on 2008/5/19 14:37:23

Hi slyss,
the unserialize() function explained by trabis is much better than parsing the string as i have worked out in your other posts! You should change your code so that you only use this function.

best regards,
Marco
Re: Drop down menu with unserlize function ?
by slyss on 2008/5/19 6:31:06

many thanks ;)
Re: Drop down menu with unserlize function ?
by trabis on 2008/5/18 22:11:04

You can test diferent outputs this way:
<?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}'; //$countries = 'a:2:{s:5:"milan";s:6:"Milano";s:6:"naples";s:6:"Napoli";}'; $data = unserialize($countries); foreach ($data as $key=>$value){ echo $key.' -> '.$value.'<br />'; } ?>


As you see one uses keys and the other does not.
Re: Drop down menu with unserlize function ?
by trabis on 2008/5/18 21:56:00

le="color: #000000"><?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}'; $data = unserialize($countries); echo $data[0];//abruzzo echo $data[1];//basilicata
Re: Drop down menu with unserlize function ?
by slyss on 2008/5/18 21:34:07

hi marco


if i have this:


le="color: #000000"><?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}';


how i can extract countries?

thanks a lot

Who's Online

162 user(s) are online (136 user(s) are browsing Support Forums)


Members: 0


Guests: 162


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits