WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] PHP multiple strings behind each other

[Resolved] PHP multiple strings behind each other

  • Hi,

    my questions is actually pretty basic since I am a PHP newbie. I am referring to this line of code:

    unset( $column_headers['coupon_items'] );

    Behind ‘coupon_items’ I would like to add more parameters, so I tried this:

    unset( $column_headers['coupon_items', 'date', 'something'] );

    Unfortunately, this leads to a php error. How can I place parameter behind each other in this case.

    Any ideas are appreciated, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Either:

    unset( $column_headers['coupon_items'], $column_headers['date'], $column_headers['something']);

    or if you have a bunch of values in the array, you could place them in a new array and loop through them.

    $unset_values = array('coupon_items', 'date', 'something');
    
    foreach( $unset_values as $val ) {
      unset( $column_headers[$val] );
    }

    Very cool, works perfect! Thank you very much 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] PHP multiple strings behind each other’ is closed to new replies.