is it possible to use HashMap in php?

Posted on 2007-04-05
Last Modified: 2010-01-14
I have done
$path = "./";
$r= opendir($path);
while ($fichier = readdir($r)){
 if (strpos($fichier,".")>0) {
// Sort the array
but I would like to sort also $dossier because $filename[$numfiles] must correspond to $dossier$numfiles]. HNow can I do? Is it possible to use hasmap in php?


Question by:pofpof98
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 29

Accepted Solution

rdivilbiss earned 500 total points
ID: 18886807
The answer is not really.

However this may do what you want.

$path = "./";
$r= opendir($path);
while ($fichier = readdir($r)){
      if (strpos($fichier,".")>0) {
            $filename[$numfiles] = substr($fichier,0,strpos($fichier,"."));
            $dossier[$numfiles] = substr($fichier,strpos($fichier,".")+1);
            $numfiles += 1;

$map = array_combine($filename, $dossier);

// Sort the array

foreach($map as $filename => $dossier) {
      echo $filename . " " . $dossier . "<br>";

LVL 29

Expert Comment

ID: 18933540
Thanks pofpof98!

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question