How do i display array in table in string ?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 551 Views - Last Post: 19 March 2019 - 10:30 AM Rate Topic: -----

#16 Ryanayao   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-March 19

Re: How do i display array in table in string ?

Posted 18 March 2019 - 04:47 PM

could tell me i'm doing this right rewrite my code for is_array to get_post but don't know where to put my implode in this function i'm unable to figure out what to do next

this function retrieve my value post for $name passed as array if dflt is not being used default value would pass non-numeric keys
function get_post($name, $dflt='')
{
	if (is_array($name)) {
		$ret = array();
		foreach($name as $key => $dflt)
			if (!is_numeric($key)) {
				$ret[$key] = is_float($dflt) ? input_num($key, $dflt) : get_post($key, $dflt);
			} else {
				$ret[$dflt] = get_post($dflt, null);
			}
		return $ret;
	} else
		return is_float($dflt) ? input_num($name, $dflt) :
				((!isset($_POST[$name]) /*|| $_POST[$name] === ''*/) ? $dflt : $_POST[$name]);
}

Was This Post Helpful? 0
  • +
  • -

#17 Ryanayao   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-March 19

Re: How do i display array in table in string ?

Posted 18 March 2019 - 05:33 PM

View PostRyanayao, on 18 March 2019 - 04:47 PM, said:

could tell me i'm doing this right rewrite my code for is_array to get_post but don't know where to put my implode in this function i'm unable to figure out what to do next

this function retrieve my value post for $name passed as array if dflt is not being used default value would pass non-numeric keys
function get_post($name, $dflt='')
{
	if (is_array($name)) {
		$ret = array();
		foreach($name as $key => $dflt)
			if (!is_numeric($key)) {
				$ret[$key] = is_float($dflt) ? input_num($key, $dflt) : get_post($key, $dflt);
			} else {
				$ret[$dflt] = get_post($dflt, null);
			}
		return $ret;
	} else
		return is_float($dflt) ? input_num($name, $dflt) :
				((!isset($_POST[$name]) /*|| $_POST[$name] === ''*/) ? $dflt : $_POST[$name]);
}


When trying to check is_array or not it display not an Array how do i solve this problem ?do i need to explode then implode ?
Was This Post Helpful? 0
  • +
  • -

#18 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: How do i display array in table in string ?

Posted 18 March 2019 - 05:50 PM

Which line of that function is the error on? If it says it's an array, then it's an array.

Also, why do you have the $dflt parameter? If $name is an array, you don't use $dflt at all, you immediately overwrite it.
Was This Post Helpful? 0
  • +
  • -

#19 Ryanayao   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-March 19

Re: How do i display array in table in string ?

Posted 18 March 2019 - 06:19 PM

$dflt is my default value when inserting numeric numbers and when im trying to check is_array on my table_header keep saying its not an array ? why
Was This Post Helpful? 0
  • +
  • -

#20 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: How do i display array in table in string ?

Posted 19 March 2019 - 10:30 AM

And you understand that you're overwriting $dflt if $name is an array, correct? You never use the value of it. You understand that, right?

Show some code where you call this function. I'd like to see examples of you using the function, and also use print_r with $_POST so we can see what's actually in $_POST when you call this function.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2