Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP echo question LIMIT output

Posted on 2011-09-28
2
Medium Priority
?
250 Views
Last Modified: 2012-08-13
I have a column  in a table that has data like: B*3B as well as data like MEDH*001

I do an echo like this:

<?php echo(rawurlencode($row_WADAINMATE['CELL_ASSIGNMENT'])); ?>

Open in new window


How do I alter this echo to only display the characters prior to the * ?
0
Comment
Question by:pda4me
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 2000 total points
ID: 36718183
<?php 

echo(rawurlencode(preg_replace('/^(.*)\*.*$/', '$1', $row_WADAINMATE['CELL_ASSIGNMENT']))); 

?>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36718816
I think the regex from Rik-Legger looks correct.  I would probably do it something like this:

$arr = explode('*', $row_WADAINMATE['CELL_ASSIGNMENT']);
echo rawurlencode($arr[0]);

http://php.net/manual/en/function.explode.php

There is also some combination of strpos() and substr() that would work, too.  Lots of ways to skin this cat!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question