Skip to main content
added 1 characters in body
Source Link
Sebsemillia
  • 169
  • 2
  • 2
  • 6

I created a custom user meat value and want to add a new key/value to this array. But somehow I can't get it to work correctly, I always get a new array in side the array so that I always have e new dimension. But I want to keep just one dimension and add the new key/value pair.

I nowknow this is nothing complicated but somehow I can't get it to work. I would appreciate any help.

my entry script:

$invoice_meta = get_user_meta( $_GET['id'], 'invoices');
$random = substr(number_format(time() * rand(),0,'',''),0,5);
if(empty($invoice_meta)) {
    $invoice_array = array();
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    add_user_meta( $_GET['id'], 'invoices', $invoice_array);
} else {
    $invoice_array = $invoice_meta;
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    update_user_meta( $_GET['id'], 'invoices', $invoice_array );
}

The first entry var_dump looks like this:

array(1) {
  [0]=>
  array(1) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf"
  }
}

after second one it looks like this:

array(1) {
  [0]=>
  array(2) {
    [0]=>
    array(1) {
      ["07.05.2013_51584"]=>
      string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_5875448693K_26.pdf"
    }
    ["07.05.2013_37016"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_58754348693K_26.pdf"
  }
}

But I want to look it like this

array(1) {
  [0]=>
  array(2) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf",
    ["07.05.2013_51534"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543367Y48693K_26.pdf"
  }
}

I created a custom user meat value and want to add a new key/value to this array. But somehow I can't get it to work correctly, I always get a new array in side the array so that I always have e new dimension. But I want to keep just one dimension and add the new key/value pair.

I now this is nothing complicated but somehow I can't get it to work. I would appreciate any help.

my entry script:

$invoice_meta = get_user_meta( $_GET['id'], 'invoices');
$random = substr(number_format(time() * rand(),0,'',''),0,5);
if(empty($invoice_meta)) {
    $invoice_array = array();
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    add_user_meta( $_GET['id'], 'invoices', $invoice_array);
} else {
    $invoice_array = $invoice_meta;
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    update_user_meta( $_GET['id'], 'invoices', $invoice_array );
}

The first entry var_dump looks like this:

array(1) {
  [0]=>
  array(1) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf"
  }
}

after second one it looks like this:

array(1) {
  [0]=>
  array(2) {
    [0]=>
    array(1) {
      ["07.05.2013_51584"]=>
      string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_5875448693K_26.pdf"
    }
    ["07.05.2013_37016"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_58754348693K_26.pdf"
  }
}

But I want to look it like this

array(1) {
  [0]=>
  array(2) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf",
    ["07.05.2013_51534"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543367Y48693K_26.pdf"
  }
}

I created a custom user meat value and want to add a new key/value to this array. But somehow I can't get it to work correctly, I always get a new array in side the array so that I always have e new dimension. But I want to keep just one dimension and add the new key/value pair.

I know this is nothing complicated but somehow I can't get it to work. I would appreciate any help.

my entry script:

$invoice_meta = get_user_meta( $_GET['id'], 'invoices');
$random = substr(number_format(time() * rand(),0,'',''),0,5);
if(empty($invoice_meta)) {
    $invoice_array = array();
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    add_user_meta( $_GET['id'], 'invoices', $invoice_array);
} else {
    $invoice_array = $invoice_meta;
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    update_user_meta( $_GET['id'], 'invoices', $invoice_array );
}

The first entry var_dump looks like this:

array(1) {
  [0]=>
  array(1) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf"
  }
}

after second one it looks like this:

array(1) {
  [0]=>
  array(2) {
    [0]=>
    array(1) {
      ["07.05.2013_51584"]=>
      string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_5875448693K_26.pdf"
    }
    ["07.05.2013_37016"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_58754348693K_26.pdf"
  }
}

But I want to look it like this

array(1) {
  [0]=>
  array(2) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf",
    ["07.05.2013_51534"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543367Y48693K_26.pdf"
  }
}
Source Link
Sebsemillia
  • 169
  • 2
  • 2
  • 6

Get custom_user meta value and add entry

I created a custom user meat value and want to add a new key/value to this array. But somehow I can't get it to work correctly, I always get a new array in side the array so that I always have e new dimension. But I want to keep just one dimension and add the new key/value pair.

I now this is nothing complicated but somehow I can't get it to work. I would appreciate any help.

my entry script:

$invoice_meta = get_user_meta( $_GET['id'], 'invoices');
$random = substr(number_format(time() * rand(),0,'',''),0,5);
if(empty($invoice_meta)) {
    $invoice_array = array();
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    add_user_meta( $_GET['id'], 'invoices', $invoice_array);
} else {
    $invoice_array = $invoice_meta;
    $invoice_array[date('d.m.Y').'_'.$random] = $pdf_save_path.$pdf_name;
    update_user_meta( $_GET['id'], 'invoices', $invoice_array );
}

The first entry var_dump looks like this:

array(1) {
  [0]=>
  array(1) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf"
  }
}

after second one it looks like this:

array(1) {
  [0]=>
  array(2) {
    [0]=>
    array(1) {
      ["07.05.2013_51584"]=>
      string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_5875448693K_26.pdf"
    }
    ["07.05.2013_37016"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_58754348693K_26.pdf"
  }
}

But I want to look it like this

array(1) {
  [0]=>
  array(2) {
    ["07.05.2013_51584"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543369Y48693K_26.pdf",
    ["07.05.2013_51534"]=>
    string(69) "user-data/26/rechnung/tierportal-d_07-05-2013_587543367Y48693K_26.pdf"
  }
}