Jump to content

Recommended Posts

Hi,

i've got a string that i need to separete. the string is always in the same length of 97 chars

here is my code that i use:
[code]
$daten = "290122105555910000 HZ LEGEND               AIR                           0001840000130200100232"
$lange = strlen($daten);
        $ean = substr($daten, 0, 13);
        $text = substr($daten, 13, 60);
        $filial_vk = substr($daten, 60, 7);
        $duch_ek = substr($daten, 67, 7);
        $mwst = substr($daten, 74, 1);
        $hw_grp = substr($daten, 75, 2);
        $uwgr = substr($daten, 77, 4);
        $status = substr($daten, 81, 1);
        echo $ean . '-' .
             $text .' - '.
             $filial_vk .' - '.
             $duch_ek . ' - '.
             $mwst . ' -  '.
             $hw_grp . ' -  '.
             $uwgr . ' - '.
             $status ."<br>\n";[/code]
but the output is only
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]2901221055559-10000 HZ LEGEND AIR - - 0 - 0 - 01 - 8400 - 0[/quote]
what is wrong with this code?

best
Link to comment
https://forums.phpfreaks.com/topic/13114-substr-problem/
Share on other sites

If you're sure of the length then this doesn't really seem like a tricky problem; to start I would remove all that white space from the string, I think that would just get in your way... try using trim(). Anyway, it also looks like some of your substr's are going from the middle/end of the string to the front, that is they are wrapping around. At any rate, it looks like $duch_ek is being set to '' which I believe is due to that white space. If you want more help then please specify what you expected to get as output and any errors thrown.
Link to comment
https://forums.phpfreaks.com/topic/13114-substr-problem/#findComment-50428
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.