Jump to content

Php Wordwrap


melchedsik

Recommended Posts

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'; ?>

Link to comment
Share on other sites

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 by ExtremeGaming
Link to comment
Share on other sites

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.