gio1961 Posted June 18, 2019 Report Share Posted June 18, 2019 Hi guys, for privacy reasons, I have to display only the name of the pilot and the first character of the last name, how can I edit this code? <?php echo $pilot->firstname.' '.$pilot->lastname?> Grace for a possible response Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 18, 2019 Administrators Report Share Posted June 18, 2019 Try this <?php echo $pilot->firstname .' '. substr ($pilot->lastname, 0, 1)?> https://www.w3schools.com/php7/func_string_substr.asp I've done the same everywhere on the user/public side of my site. On the admin side, I still show complete last name. 1 Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 19, 2019 Author Report Share Posted June 19, 2019 (edited) 10 hours ago, ProAvia said: Try this <?php echo $pilot->firstname .' '. substr ($pilot->lastname, 0, 1)?> https://www.w3schools.com/php7/func_string_substr.asp I've done the same everywhere on the user/public side of my site. On the admin side, I still show complete last name. Thank you. Very kind <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h5><?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="/en/lib/skins/crewcenter/images/pilot.png" class="img-circle" alt="User Image" height="20"> <img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).' " width="17" height="17" />'; echo ' <Strong>'.$pilot->firstname.'</strong> '.$pilot->lastname.'<br />'; echo '<small></small>'; echo "</p>"; } ?> On the highlighted line I have problems Edited June 19, 2019 by gio1961 Quote Link to comment Share on other sites More sharing options...
PaintSplasher Posted June 19, 2019 Report Share Posted June 19, 2019 <h5> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="/en/lib/skins/crewcenter/images/pilot.png" class="img-circle" alt="User Image" height="20"> <img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).' " width="17" height="17" />'; echo ' <strong>'.$pilot->firstname.'</strong> '.substr($pilot->lastname, 0, 1).'<br />'; echo '<small></small>'; echo "</p>"; } ?> Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 19, 2019 Author Report Share Posted June 19, 2019 5 minutes ago, PaintSplasher said: <h5> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="/en/lib/skins/crewcenter/images/pilot.png" class="img-circle" alt="User Image" height="20"> <img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).' " width="17" height="17" />'; echo ' <strong>'.$pilot->firstname.'</strong> '.substr($pilot->lastname, 0, 1).'<br />'; echo '<small></small>'; echo "</p>"; } ?> Thank you. Quote Link to comment 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.