Search the Community
Showing results for tags 'php substr()'.
-
Hello all. I have a sports league database where when a team registers as a “returning team” from last year, it queries a table that contains the basic information from last year’s team names, league, night and division. Simple enough. However I would like to do two things to the data in the array. First, I want to take two fields ‘firstname’ and ‘lastname’ and create an output that lists only the first character of the ‘firstname’, add a dot, then the ‘lastname’ i.e. J. Doe as the output. Second, I want to limit the number of characters in the ‘teamname’ field to no more than 25 characters, and if it’s over 25 characters, limit the output to 25 characters then 3 dots ‘…’ For example if the teamname was “Twenty Five Crazy Characters Team” it would be cut to “Twenty Five Crazy Charact…” to limit the size of the field I am using. I basically only have 5 strings I am working with. “season” “league” “teamname” and “firstname” and of course “lastname”. I am simply having the hardest time manipulating the array data to output as I have written above. I have hit a wall here. Was hoping some type of substr() statement would help, but alas it is not working. PHP coders, I NEED YOUR HELP! Thanks in advance! <select name="ret_teamname" id="ret_teamname" tabindex="4" > <option value="" selected="selected">-- Select Returning Team --</option> <?php while ($lrow = mssqlfetchassoc($rres)) { ?> <option value="<?php echo $lrow['l_id'];?>"><?php echo "$lrow[season] $lrow[leaguename] $lrow[rteamname] $lrow[firstname] $lrow[lastname]"; ?></option> <?php } ?> </select>