Jump to content

Recommended Posts

I'm trying to get my Array which list the characters to list 'Alphabetically', but am unable to do so. At the moment, everyone who has replies is featured as I'd like but they're names are listing in alphabetical order as I'd like. I've tried some sort()s and other things but nothing has worked.

Any help is appreciated (I'm starting college to study web this Month!)

<?php
if ($featuring && $charid) 'ORDER BY featuring, codeName'; {
?>
<tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td>
<td><p><font color="#A5B9D5"><?php

list ($featuring, $charList) = linkCharsAdvanced($featuring, $id);
   
echo $featuring; 

?>

 

 

 

 

Thank you for the suggested direction Maq,

    I've been googling 'Sort' 'how to order an array alphabetically' and having little success (I don't know what i'm doing, and i just do lots of trial and error. I will now go off and look at this new option which I doubt i would have found by myself. I will also likely be back here in an hour with more questions.

    Thank you for the assist! Wish me luck!

    -Chez

I attempted to use the sort option again (but I don't grock 'SORT' what so ever.)

 

I'm not getting the following error listing, everything is still working as it was, but this error reads above the array i'm trying to have display/sort alphabetically.

 

'Warning: sort() expects parameter 1 to be array, string given in /home/content/z/a/n/zanland/html/xpg/messages/displayX.php on line 111

CHANT, SPEED, OBSIDIAN, ANIMA'

 

The names 'CHANT, SPEED, OBSIDIAN, ANIMA' is what i'm trying to get to list as 'ANIMA, CHANT, SPEED, OBSIDIAN'.

 

 

Below is my revised code:

<?php
if ($featuring && $charid) 'ORDER BY featuring, codeName'; {
?>
<tr><td align="right" width="100"><p><font color="#A5B9D5"><b>Who:</b></font></p></td><td width="10"></td>
<td><p><font color="#A5B9D5"><?php

list ($featuring, $charList) = linkCharsAdvanced($featuring, $id);

sort($featuring);
for($i=0; $i<8; $i++)
{
print $narray[$i] . "";
}
   
echo $featuring; 

?>

 

 

Hello Thorpe - I COMPLETELY forgot that I built that as a function, or as an attempted a while back (THANK YOU! YOU ARE SUPER HELPFUL). I honestly thought i was calling an ARRAY.

 

Below is my wacky function which I want to list characters alphabetically (So it would work like Crayon mentioned). I have the functions called out from the main page in a file called functions.php which someone on here told me to do last year.

 

[#]

 

function linkCharsAdvanced ($text, $post) {

list($codenameList,$codenameID,$appearanceList) = listChars();

$text = preg_replace("/\//","}",$text);

$charids = array();

 

$replaceArray = array();

FOR ($z=0; $z < count ($codenameList); $z++) {

$thisName = addslashes($codenameList[$z]);

$searchName = preg_replace("/\./","\.",$thisName);

$searchName = preg_replace("/\//","}",$thisName);

 

$text = preg_replace("/$searchName([, \.;:\)&])/","[[$z]]$1", $text);

$text = preg_replace("/$searchName$/","[[$z]]", $text);

$replaceArray[$z] = "<a href=\"/cerebra/display.php?id=$codenameID[$z]\" id='cerebra_$codenameID[$z]_$post'>$codenameList[$z]</a>";

 

$thisName = preg_replace("/\./","\.",$codenameList[$z]);

 

} // end FOR

 

FOR ($z=0; $z < count ($codenameList); $z++) {

$oldtext=$text;

$text = preg_replace("/\[\[$z\]\]/","$replaceArray[$z]", $text);

if ($oldtext != $text) { array_push($charids, $codenameID[$z]); }

} // end FOR

 

$text = preg_replace("/}/","/", $text);

return array(stripslashes($text), $charids);

 

} // end FUNCTION[#]

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.