Hello Everyone ! How to split each array to own variable and display that variable separately . I got code from IP API provider to display user's location,

include 'ip2locationlite.class.php';
$ipLite = new ip2location_lite;
$ipLite->setKey('c86c104532b5466bda7620b48e20b10ca53ad9070b8cc52b5a5d90a6e57b9bb3');
$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();

echo "<strong>First result</strong><br />\n";
echo count($locations);

echo '<br><br>';
  foreach ($locations as $field => $val) 
  {
	echo $field . ' : ' . $val . "<br />\n";
  }
echo '<br><br>';

Visit This Example

Nw how to seperate each array to each variables ?

Recommended Answers

All 5 Replies

Member Avatar for diafol

Have a look at extract and list

Hi ardav ! yes i used it, but i dnt know how to ? I need to display $variables without using any loop.. Is there any solutions ?

Member Avatar for diafol
extract($locations,EXTR_OVERWRITE);
echo $ipAdress;

choose the appropriate flag parameter for extract

Hi ardav, Its worked fine, Thank You so so much.. You saved my time... Thank you so much ardav !!:)

Member Avatar for diafol

OK, mark as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.