?
Solved

CS6 Adobe Dreamweaver Alphanumeric list

Posted on 2016-09-21
4
Medium Priority
?
180 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 53

Expert Comment

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

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

Accepted Solution

by:
Ryan Chong earned 2000 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 53

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …
Suggested Courses

770 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