954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Array Split

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>\n";
echo count($locations);

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


Visit This Example

Nw how to seperate each array to each variables ?

mohamedasif18
Junior Poster in Training
61 posts since Nov 2011
Reputation Points: 10
Solved Threads: 5
 

Have a look at extract and list

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

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 ?

mohamedasif18
Junior Poster in Training
61 posts since Nov 2011
Reputation Points: 10
Solved Threads: 5
 
extract($locations,EXTR_OVERWRITE);
echo $ipAdress;


choose the appropriate flag parameter for extract

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

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

mohamedasif18
Junior Poster in Training
61 posts since Nov 2011
Reputation Points: 10
Solved Threads: 5
 

OK, mark as solved.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You