suttercain Posted March 28, 2007 Share Posted March 28, 2007 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 https://forums.phpfreaks.com/topic/44661-solved-can-i-include-a-file-with-a-variable/ Share on other sites More sharing options...
Lumio Posted March 28, 2007 Share Posted March 28, 2007 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 https://forums.phpfreaks.com/topic/44661-solved-can-i-include-a-file-with-a-variable/#findComment-216867 Share on other sites More sharing options...
shaunrigby Posted March 28, 2007 Share Posted March 28, 2007 Post Removed Link to comment https://forums.phpfreaks.com/topic/44661-solved-can-i-include-a-file-with-a-variable/#findComment-216869 Share on other sites More sharing options...
suttercain Posted March 28, 2007 Author Share Posted March 28, 2007 Man I am such a douche. I can't believe I didn't see that. Thank you very much for your help. Link to comment https://forums.phpfreaks.com/topic/44661-solved-can-i-include-a-file-with-a-variable/#findComment-216873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.