PHP CodeIgniter Intercept Data

Source: Internet
Author: User
Tags eol codeigniter


15018903588-006


In the middle there is a horizontal bar, how to according to the middle of the front of the bar to intercept the data, and then in accordance with the horizontal bar to the back of the data truncated


To find the prawn code to paste out


Reply to discussion (solution)

$str = ' 15018903588-006 '; $last = substr ($str, 0,strrpos ($str, '-')); $next = substr (Strstr ($str, '-'), 1); Echo $last, Php_ Eol;echo $next

$str = ' 15018903588-006 '; $last = substr ($str, 0,strrpos ($str, '-')); $next = substr (Strstr ($str, '-'), 1); Echo $last, Php_ Eol;echo $next


Here is the data I have shown, can you write the following?

The result is: 15018903588

---------------------------------------------------------------

concluded: 006

I understand, right?




$str = ' 15018903588-006 '; $last = substr ($str, 0,strrpos ($str, '-')); $next = substr (Strstr ($str, '-'), 1); Echo $last, Php_ Eol;echo $next


Here is the data I have shown, can you write the following?

The result is: 15018903588

---------------------------------------------------------------

concluded: 006

I understand, right?




Yes


foreach ($info as $key = $value)
{
?>











Strange values do not show up.
------------------------------------------------------
It can be shown below.

foreach ($info as $key = $value)
{
?>











$str = ' 15018903588-006 '; $last = substr ($str, 0,strrpos ($str, '-')); $next = substr (Strstr ($str, '-'), 1); Echo $last, Php_ Eol;echo $next


Here is the data I have shown, can you write the following?

The result is: 15018903588

---------------------------------------------------------------

concluded: 006

I understand, right?




Yes








-------------------------------------------
Yes, some numbers are no job number, how to verify, such as without the work number of




$str = ' 15018903588-006 '; $last = substr ($str, 0,strrpos ($str, '-')); $next = substr (Strstr ($str, '-'), 1); Echo $last, Php_ Eol;echo $next


Here is the data I have shown, can you write the following?

The result is: 15018903588

---------------------------------------------------------------

concluded: 006

I understand, right?




Yes








-------------------------------------------
Yes, some numbers are no job number, how to verify, such as without the work number of
Determine whether the work number exists, is intercepted, does not exist on the skip


foreach ($info as $key = $value)
{
?>











Strange values do not show up.
------------------------------------------------------
It can be shown below.

foreach ($info as $key = $value)
{
?>









Determine if there is a value present, so there is no problem
$value [' homa '] = ' 15018903588-006 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));
?>



foreach ($info as $key = $value)
{
?>











Strange values do not show up.
------------------------------------------------------
It can be shown below.

foreach ($info as $key = $value)
{
?>









Determine if there is a value present, so there is no problem
$value [' homa '] = ' 15018903588-006 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));
?>

--------------------------------------------------
Yes, but some of the data are not with work numbers, such as:



foreach ($info as $key = $value)
{
?>











Strange values do not show up.
------------------------------------------------------
It can be shown below.

foreach ($info as $key = $value)
{
?>









Determine if there is a value present, so there is no problem
$value [' homa '] = ' 15018903588-006 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));
?>
------------------------------------------------------------
$value [' homa '] = ' 15018903588 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));

$value [' homa '] = ' 057120826666 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));



foreach ($info as $key = $value)
{
?>











Strange values do not show up.
------------------------------------------------------
It can be shown below.

foreach ($info as $key = $value)
{
?>









Determine if there is a value present, so there is no problem
$value [' homa '] = ' 15018903588-006 ';
Echo substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));
?>
-------------------------------------------
Data values:
15018903588-006
057188888881-007
05718888888-007
15018903588

The above is a value that shows one of the data

The effect I want to achieve is:
The bar before and after the data are intercepted, no horizontal bar directly displayed

Determine if the work number has "-"
if (Strpos ($value [' Homa '], '-')) {
$last = substr ($value [' Homa '],0,strrpos ($value [' Homa '], '-'));
$next = substr (Strstr ($value [' Homa '], '-'), 1);
}else{
$value [' Homa '];
}

Yes, thank you.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.