Jump to content

Order() code fix.


k0z

Recommended Posts

Hi, This is my current code:

 

<?php

 

 

$favorites=2;

$recent=1;

 

 

$given_array = array("favorites"=>$favorites, "recent"=>$recent);

$abc = order_array($given_array);

 

function order_array ($given_array) {

 

 

sort($given_array);

 

foreach($given_array as $key => $value) {

echo $value . ':';

  }

 

}

 

?>

 

This code returns "1:2:"

The problem is, this is returning the values of the strings that were defined at the top of the code. Instead of returning their values, i want it to return their names. So in this case, it would return "recent:favorites:"

How do i do this?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/173368-order-code-fix/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.