Jump to content

[SOLVED] Array to String


monkeypaw201

Recommended Posts

Is there a way to convert array to string? I'm not sure thats what I need, but something isn't working.. what step did i overlook?

 

<?php
#Link files into variables
$vatsim_file = file($vatsim);
$metacraft_file = file($metacraft);
$fsproshop_file = file($fsproshop);

#Get the last UPDATE variable
$vatsim_time = substr($vatsim_file,2543,14);
$metacraft_time = substr($metacraft_file,2543,14);
$fsproshop_time = substr($fsproshop_file,2543,14);
?>

 

Outputs:

 

Notice: Array to string conversion in /incoming.php on line 23

 

Notice: Array to string conversion in /incoming.php on line 24

 

Notice: Array to string conversion in /incoming.php on line 25

Link to comment
https://forums.phpfreaks.com/topic/119354-solved-array-to-string/
Share on other sites

Well, file() reads a file as an array and substr() expects a string object. Not sure what you are trying to accomplish, but you could use implode() to convert the file contents into a string or, probably better, use file_get_contents() to read the file as a string to begin with.

 

<?php
#Link files into variables
$vatsim_file = file_get_contents($vatsim);
$metacraft_file = file_get_contents($metacraft);
$fsproshop_file = file_get_contents($fsproshop);

#Get the last UPDATE variable
$vatsim_time = substr($vatsim_file,2543,14);
$metacraft_time = substr($metacraft_file,2543,14);
$fsproshop_time = substr($fsproshop_file,2543,14);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.