Home » Php » How do I write a square bracket in a php function

How do I write a square bracket in a php function

Posted by: admin February 25, 2020 Leave a comment

Questions:

I need to write a function to cut off a string at the “[” (square bracket).

This is what I got so far

function desc_sli( $slice= '' ) {
    $sliceVal = strtok( $slice, '[');
    return $sliceVal;
}

It doesn’t work with the square bracket (with other letters and symbols it does)
I suspect there must be a different notation for ‘[‘ since the square bracket is also used in functions and arrays. Though I am not able to find it. Anyone who can help me out?

Thanks!

How to&Answers: