Jump to content

[SOLVED] Can I Include a file with a variable?


suttercain

Recommended Posts

I have an include file which has an array an it is assigned a variable. I include the file

 include ('vehicle_array');

 

That file contains this array

<?php
$makes = array('ACUR'=>'ACURA', 
		   'ALP'=>'ALPINA', 
		   'ASMA'=>'ASTON MARTIN LAGONDA',
		   'AUDI'=>'AUDI',
		   'BAF'=>'FORD BAF CNG',
		   'BAYT'=>'GENERAL MOTORS BAYTECH CNG',
		   'BENT'=>'BENTLY',
		   'BMW'=>'BMW',
		   'BUIC'=>'BUICK',
		   'CAD'=>'CADILLAC',
		   'CHEV'=>'CHEVROLET',
		   'CHRS'=>'CHRYSLER',
		   'CUMM'=>'CUMMINS',
		   'DODG'=>'DODGE',
		   'FERI'=>'FERARAI',
		   'FORD'=>'FORD',
		   'GMC'=>'GMC',
		   'HOND'=>'HONDA',
		   'HUMM'=>'HUMMER',
		   'HYND'=>'HYUNDAI',
		   'INFI'=>'INFINITI',
		   'ISUZ'=>'ISUZU',
		   'JAG'=>'JAGUAR',
		   'JEEP'=>'JEEP',
		   'KI'=>'KIA',
		   'LAMB'=>'LABORGHINI',
		   'LAND'=>'LAND ROVER',
		   'LEXS'=>'LEXUS',
		   'LINC'=>'LINCOLN',
		   'LOTU'=>'LOTUS',
		   'MASE'=>'MASERATI',
		   'MAZD'=>'MAZDA',
		   'MBZ'=>'MERCEDES BENZ',
		   'MINI'=>'MINI',
		   'MITS'=>'MITSUBISHI',
		   'MORG'=>'MORGAN',
		   'MRCY'=>'MERCURY',
		   'NISS'=>'NISSAN',
		   'PONT'=>'PONTIAC',
		   'PORS'=>'PORSCHE',
		   'RPP'=>'ROUSCH',
		   'RR'=>'ROLLS ROYCE',
		   'SAAB'=>'SAAB',
		   'SALE'=>'SALEEN',
		   'SATU'=>'SATURN',
		   'SHLB'=>'SHELBY',
		   'SUBA'=>'SUBARU',
		   'SUZU'=>'SUZUKI',
		   'TOTA'=>'TOYOTA',
		   'VOLK'=>'VOLKSWAGEN',
		   'VOLV'=>'VOLVO',
		   );

 

That array was in the original .php file, which works fine when it's there. But when I replace it with the include instead it doesn't show up.

 

What am I doing incorrect?

 

Thank you.

Link to comment
Share on other sites

you have to name the file with .php and call it like:

<?php include('filename.php'); ?>

and filename.php contains your array:

<?php
$makes = array('ACUR'=>'ACURA', 
		   'ALP'=>'ALPINA', 
		   'ASMA'=>'ASTON MARTIN LAGONDA',
		   'AUDI'=>'AUDI',
		   'BAF'=>'FORD BAF CNG',
		   'BAYT'=>'GENERAL MOTORS BAYTECH CNG',
		   'BENT'=>'BENTLY',
		   'BMW'=>'BMW',
		   'BUIC'=>'BUICK',
		   'CAD'=>'CADILLAC',
		   'CHEV'=>'CHEVROLET',
		   'CHRS'=>'CHRYSLER',
		   'CUMM'=>'CUMMINS',
		   'DODG'=>'DODGE',
		   'FERI'=>'FERARAI',
		   'FORD'=>'FORD',
		   'GMC'=>'GMC',
		   'HOND'=>'HONDA',
		   'HUMM'=>'HUMMER',
		   'HYND'=>'HYUNDAI',
		   'INFI'=>'INFINITI',
		   'ISUZ'=>'ISUZU',
		   'JAG'=>'JAGUAR',
		   'JEEP'=>'JEEP',
		   'KI'=>'KIA',
		   'LAMB'=>'LABORGHINI',
		   'LAND'=>'LAND ROVER',
		   'LEXS'=>'LEXUS',
		   'LINC'=>'LINCOLN',
		   'LOTU'=>'LOTUS',
		   'MASE'=>'MASERATI',
		   'MAZD'=>'MAZDA',
		   'MBZ'=>'MERCEDES BENZ',
		   'MINI'=>'MINI',
		   'MITS'=>'MITSUBISHI',
		   'MORG'=>'MORGAN',
		   'MRCY'=>'MERCURY',
		   'NISS'=>'NISSAN',
		   'PONT'=>'PONTIAC',
		   'PORS'=>'PORSCHE',
		   'RPP'=>'ROUSCH',
		   'RR'=>'ROLLS ROYCE',
		   'SAAB'=>'SAAB',
		   'SALE'=>'SALEEN',
		   'SATU'=>'SATURN',
		   'SHLB'=>'SHELBY',
		   'SUBA'=>'SUBARU',
		   'SUZU'=>'SUZUKI',
		   'TOTA'=>'TOYOTA',
		   'VOLK'=>'VOLKSWAGEN',
		   'VOLV'=>'VOLVO',
		   );
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.