Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6655977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:35:13+00:00 2026-05-26T01:35:13+00:00

So I am new to PHP and I am having some difficulty with the

  • 0

So I am new to PHP and I am having some difficulty with the trim function.

Basically I need to

  • trim @example.com from all agent_email values.
  • trim the traffic_source down to 30 characters i.e. http://www.example.com/ex/test…

Here is my source code.

<?php

include "../include/setup.inc.php";


$query="SELECT offer_id,title,email,phone,site,zip,price,return_customer,request_date,traffic_source,agent_email,released FROM jos_quote 
     where request_date >= '2011-10-04' order by request_date";
$result = mysql_query($query);          
    if (!$result) {echo "<p><b>".$query ."</b></p>";echo 'MySQL Error: ' . mysql_error(); return;}
$num_rows = mysql_num_rows($result);
    echo '<br><table border="1" align="center" width="700px">
     <tr bgcolor="#FF8000"><td colspan="11" align="center">Total: '.$num_rows.'quotes -  Date Range: '.$_POST['date1'].' -- '.$_POST['date2'].' </td></tr>
     <tr><th>Title</th><th>Email</th><th>Site</th><th>Zip</th><th>Price</th>
<th>Return Customer</th><th>Request Date</th><th>Agent</th><th>Released</th><th>Traffic Source</th>';
while ($row = mysql_fetch_assoc($result)) {
    echo '<tr>
    <td>'.$row['title'].'</td>
    <td>'.$row['email'].'</td>
    <td>'.$row['site'].'</td>
    <td>'.$row['zip'].'</td>
    <td>'.$row['price'].'</td>                               
    <td>'.$row['return_customer'].'</td>                                
    <td>'.$row['request_date'].'</td>                                
    <td>'.$row['agent_email'].'</td>                                    
    <td>'.$row['released'].'</td>                                
     <td>'.$row['traffic_source'].'</td>                                                 
     </tr>';
}
echo '</table>';
$query="select agent_email,num_quote,num_receive,set_date from quote_distro where set_date  >= '2011-10-04'";
$result = mysql_query($query);          
    if (!$result) {echo "<p><b>".$query ."</b></p>";echo 'MySQL Error: ' . mysql_error();     return;}
    while ($row = mysql_fetch_assoc($result)) {
$quote_info[$row['agent_email']][$row['set_date']] =$row;

}


}


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:35:14+00:00Added an answer on May 26, 2026 at 1:35 am

    That’s not what the trim() function does. trim() strips whitespace from the beginning and the end of a string.

    I need to trim @example.com from all agent_email values.

    You can use str_replace for that. For example to remove @example.com from a String.

    $string = str_replace ('@example.com', '', $string);
    

    If instead you want to remove whatever after the at sign (@), you can use explode:

    list($string) = explode('@', $string);
    

    I also need to trim the traffic_source down to 30 characters

    This is again another concept. You can use php substr function for that:

    $string = substr($string, 0, 30);
    

    If you want to add ellipsis sign only when the string was truncated:

    if (strlen($string) > 30) {
        $string = substr($string, 0, 30) . '&hellip;';  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble translating a subroutine from Perl to PHP (I'm new to Perl).
I'm new to PHP and I'm confused seeing some examples calling a function with
Having some trouble sending properly formatted HTML e-mail from a PHP script. I am
Currently I’m having some difficulties with using new Magento's soap v2 from c# interface.
I'm new to php and am having some trouble with inserting data across multiple
I've got a new site setup using CMSMadeSimple (PHP based) but I'm having problems
I'm having some difficult with PHP DOM class. I am making a sitemap script,
I'm having some trouble extending Classes in PHP. Have been Googling for a while.
I'm fairly new to Zend and am having some difficulties with creating my unit
I'm building a new project and I'm having some debate over how it needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.