What is the php regular expression to get everything before a certain character?

by 1 replies
2
#programming #character #expression #php #regular
  • Using a regular expression here is not what you need. Instead, you should explode the string using the ":" as the delimiter. The explode() function splits up strings into an array, using whatever symbol you like to break it.
    PHP Code:
    string "table:column";
    $ array = 
    explode(":", $ string);
    //now, $ array  is ([0] => "table", [1] => "column") 
    I had to place a space between the $ and the variable name, because for some reason the forum was removing them

Next Topics on Trending Feed