Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2004, 08:48 PM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default sort array of strings error

Could you please let me know how I can solve the following problem with array sort.

After I sort and delete duplicates from array $keywords_main of strings I get following changes to array elements:

CASE 1:
Before sort => [3, 5, 7]
sort:
$keywords_main = array_flip($keywords_main);
array_multisort($keywords_main);
$keywords_main = array_flip($keywords_main);

After sort => [0, 1, 2]

CASE 2:
(notice: there is space between 5 and 5 in second array element)
Before sort => [33, 5 5, 7]
sort:
$keywords_main = array_flip($keywords_main);
array_multisort($keywords_main);
$keywords_main = array_flip($keywords_main);

After sort => [ 0, 5 5, 1]

I would like to have array not change the value of its elements to the position number as it happens in this case. If array elements are words, then there is no problem.

Thank you,
 
Old December 14th, 2004, 08:52 PM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure if I posted to right forum...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort unrelated strings johngavin XSLT 7 January 8th, 2008 07:49 AM
strings as array indexes cwalton Excel VBA 3 July 30th, 2007 02:50 AM
Array of Strings to dll jjd Excel VBA 2 February 26th, 2006 07:25 AM
Array of Strings jjd Visual C++ 1 June 23rd, 2005 02:56 PM
Sorting Array of date strings Arsi C# 4 October 22nd, 2004 04:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.