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.