WordPress.org

Forums

[resolved] PHP multiple strings behind each other (3 posts)

  1. soralsokal
    Member
    Posted 1 year ago #

    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!

  2. SpankMarvin
    Member
    Posted 1 year ago #

    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] );
    }
  3. soralsokal
    Member
    Posted 1 year ago #

    Very cool, works perfect! Thank you very much :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.