php - Why is array_combine not returning an array? -


when try print array returned function, blank screen.

my array $terms , $definitions both same length , exist before , after call make_associative_array().

function make_associative_array() {     return array_combine($terms, $definitions); }  $c = make_associative_array(); print_r($c); 

$terms:

array (       [0] => nock (verb) [1] => end [2] => serving [3] => nock (noun)  ) 

$definitions:

array (       [0] => place arrow against string prior shooting. [1] => group of arrows shot during tournament. 6. [2] => thread wound around bow string protect string. [3] => notch @ rear of arrow. bow string placed in nock.  ) 

i using php 5.6.27

in case - array_combine returns null because both $terms & $definitions null inside scope of make_associative_array.

you can either make them global:

function make_associative_array() {     global $terms, $definitions;     return array_combine($terms, $definitions); } 

or pass them function:

function make_associative_array($terms, $definitions) {     return array_combine($terms, $definitions); } $c = make_associative_array($terms, $definitions); 

anyway - advise turn on errors:
http://sandbox.onlinephpfunctions.com/code/40cfd2d197aebd4d935c793c1ea662cab50ce8b1


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -