below mentioned is a part of my total script and I want to store this value to MySQl
I dont know how to use implode function here!! can any one help me??
$countries = array();
foreach ($my_data as $node)
{
foreach($node->getElementsByTagName('a') as $href)
{
preg_match('/([0-9\.\%]+)/',$node->nodeValue, $match);
$countries[trim($href->nodeValue)] = $match[0];
}
}
foreach ($countries as $country => $percent) echo str_replace("Â","",(strip_tags($country))) . ' - ' . str_replace("Â","",(strip_tags($percent)));
Why don't you use serialize() to convert the array into a string representation before storing it and unserialize() when retrieving it?
See this link: http://www.evolt.org/node/60222
All you have to do is: $serialized_country=serialize($country)
and then store the $serialized_country in your database.
And then when you retrieve the same from the database use something like:
$country=unserialize($serialized_country)
Hope that helps.... but keep in mind, if you have to retrieve this data many number of time repeatedly in your application, then you might have to bother about the overhead of serializing and unserializing the data each time.