douxiajiao8445
douxiajiao8445
2017-02-02 14:55

在PHP中的vb6 Mid函数

I'm developing a project ,written before in vb6, using PHP.

I have variable called VLSALESITEMID as string

Then a select. (VGID)

Then

VLSALESITEMID=VLSALESITEMID & VGID.field("SALESITEMID").Value & ","

Then

VLSALESITEMID=Mid(VLSALESITEMID, 1, Len(VLSALESITEMID) -1).

I want to translate it to php, any help?

MID FUNCTION :

' Creates text string. 
Dim TestString As String = "Mid Function Demo" 
' Returns "Mid". 
Dim FirstWord As String = Mid(TestString, 1, 3)
' Returns "Demo". 
Dim LastWord As String = Mid(TestString, 14, 4)
' Returns "Function Demo". 
Dim MidWords As String = Mid(TestString, 5)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • drwu24647 drwu24647 4年前

    The VB6 Mid function is very similar to PHP's substr function.

    <?php
    // Creates text string. 
    $TestString = 'Mid Function Demo';
    
    // Returns "Mid". 
    $FirstWord = substr($TestString, 0, 3);
    
    // Returns "Demo".
    $LastWord = substr($TestString, 13, 4);
    
    // Returns "Function Demo".
    $MidWords = substr($TestString, 4);
    
    echo
    '"', $FirstWord, '"<br />', "
    ",
    '"', $LastWord, '"<br />', "
    ",
    '"', $MidWords, '"';
    

    Will output:

    "Mid"
    "Demo"
    "Function Demo"

    点赞 评论 复制链接分享

为你推荐