Solved

CS6 Adobe Dreamweaver Alphanumeric list

Posted on 2016-09-21
4
110 Views
Last Modified: 2016-09-27
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
Comment
Question by:Samson Gilkinson
  • 3
4 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41808415
var products =["Printer","Tablet","Router"];

what programming language is referring to as what showing above?
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41808429
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
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41808443
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
 

Author Closing Comment

by:Samson Gilkinson
ID: 41817722
Thanks man, I figured it out just after this but this should answer the question for others too.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

856 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