melchedsik Posted October 25, 2012 Share Posted October 25, 2012 Hello, i am having problems where on users profiles where they can write a bio about themselves after 60 characters it start running over on my design. How can i from the existing php code below make it where it goes to 50 characters then wraps to the second line the after 50 characters go to third line until 500 word max is reached? Here is a copy of the code: <?php include 'core/init.php'; include 'includes/overall/header.php'; ?> <h1>Users</h1> <?php $users = list_users(4, (isset($_GET['page']) && $_GET['page'] != 0) ? $_GET['page'] : 1); $pages = $users['pages']; unset($users['pages']); foreach($users as $user) { ?> <div class="user"> <a href="profile.php?username=<?php echo $user['username']; ?>"><img src="<?php echo $user['profile']; ?>"></a> <div class="data"> <h2><a href="profile.php?username=<?php echo $user['username']; ?>"><?php echo $user['username']; ?></a> (<?php echo $user['first_name'], ' ', $user['last_name']; ?>)</h2> <p><?php echo $user['email']; ?></p> <p><?php echo (empty($user['bio']) === false) ? substr($user['bio'], 0,60) . '...' : ''; ?></p> </div> <div class="clear"></div> </div> <?php } for($x = 1; $x <= $pages; $x++) { ?> <a href="users.php?page=<?php echo $x; ?>"><?php echo $x; ?></a> <?php } ?> <?php include 'includes/overall/footer.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/269902-php-wordwrap/ Share on other sites More sharing options...
MDCode Posted October 25, 2012 Share Posted October 25, 2012 (edited) I'm not sure there is a way that won't be messy, but with css you can use: word-wrap: break-word; That will make sure it does not overlap. Make sure you put that where the information is being displayed Edited October 25, 2012 by ExtremeGaming Quote Link to comment https://forums.phpfreaks.com/topic/269902-php-wordwrap/#findComment-1387697 Share on other sites More sharing options...
Jessica Posted October 25, 2012 Share Posted October 25, 2012 Give the div a width. Quote Link to comment https://forums.phpfreaks.com/topic/269902-php-wordwrap/#findComment-1387698 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.