jasonc Posted October 15, 2011 Share Posted October 15, 2011 My query gets the results and orders by one of the fields. Once I get the MySQL results I would like to find the first entry that has a letter as the first character of the same field that the list was ordered by, then split the results in to two parts and swap them. So that the results that have a letter at the start of the same sorted field are as the begining and the results that have the numbers as the start at the end of the array. But also so that the array works the same way as the original results string, so i can use say $results['mysqlfield'] Quote Link to comment https://forums.phpfreaks.com/topic/249170-split-array-up-in-two-parts-and-swap-part-a-and-part-b-around/ Share on other sites More sharing options...
trq Posted October 15, 2011 Share Posted October 15, 2011 Post your code and a description of your actual problem. Quote Link to comment https://forums.phpfreaks.com/topic/249170-split-array-up-in-two-parts-and-swap-part-a-and-part-b-around/#findComment-1279654 Share on other sites More sharing options...
jasonc Posted October 16, 2011 Author Share Posted October 16, 2011 When I get the results from the following... SELECT * FROM `products` ORDER BY `productTitle` ASC it returns all results in full alphanumeric order (ascii) but this causes the entries that start with numbers to be at the start or the results. I have already asked here before to get a query that would reorder it full order numbers first then the letters after. But this seem like it can not be done as the queries I was given only order by the 'first' letter and not the rest of the text in the row. So opting for a hopefully simpler way by getting mysql to order them correctly in alphanumeric order and then splitting the results in to two parts where the rows start to contain letters and swapping them. i.e. 0123 1234 2345 3456 abc bcd cde def then swap so it looks like this... abc bcd cde def 0123 1234 2345 3456 Quote Link to comment https://forums.phpfreaks.com/topic/249170-split-array-up-in-two-parts-and-swap-part-a-and-part-b-around/#findComment-1279722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.