Solved

CS6 Adobe Dreamweaver Alphanumeric list

Posted on 2016-09-21
4
144 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
[X]
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
  • 3
4 Comments
 
LVL 52

Expert Comment

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

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

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 52

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

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