• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

CS6 Adobe Dreamweaver Alphanumeric list

Hello,
         I have an issue with cs6 that i can not figure out. I have tried sorting with php, however it doesn't seem to work. I have spent 1 hour researching this and cannot find an answer to how to sort it, please help. I need to alphanumerically order this array.
      var products =["Printer","Tablet","Router"];
0
Samson Gilkinson
Asked:
Samson Gilkinson
  • 3
1 Solution
 
Ryan ChongCommented:
var products =["Printer","Tablet","Router"];

what programming language is referring to as what showing above?
0
 
Ryan ChongCommented:
if it's Javascript, try:

products.sort();

Open in new window


like:
<!DOCTYPE html>
<html>
<body>

<p>Click the button to sort the array.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>
<p id="demo2"></p>

<script>
var products = ["Printer", "Tablet", "Router"];
document.getElementById("demo").innerHTML = products;

function myFunction() {
    products.sort();
    document.getElementById("demo2").innerHTML = products ;
}
</script>

</body>
</html>

Open in new window

0
 
Ryan ChongCommented:
if you have array in php, after is the wrong syntax, and you can try this instead:
<?php
$products = array("Printer","Tablet","Router");
$clength = count($products);

echo "Before:<br>";

for($x = 0; $x < $clength; $x++) {
    echo $products[$x];
    echo "<br>";
}

sort($products);

echo "<br>After:<br>";

for($x = 0; $x < $clength; $x++) {
    echo $products[$x];
    echo "<br>";
}
?>

Open in new window

0
 
Samson GilkinsonAuthor Commented:
Thanks man, I figured it out just after this but this should answer the question for others too.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now