Solved

CS6 Adobe Dreamweaver Alphanumeric list

Posted on 2016-09-21
4
55 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 49

Expert Comment

by:Ryan Chong
Comment Utility
var products =["Printer","Tablet","Router"];

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

Accepted Solution

by:
Ryan Chong earned 500 total points
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
Thanks man, I figured it out just after this but this should answer the question for others too.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now