php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44512 Cannot use string offset as an array
Submitted: 2008-03-23 14:23 UTC Modified: 2008-03-23 14:56 UTC
From: gogulas at wp dot pl Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2CVS-2008-03-23 (CVS) OS: WIndows Xp SP3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gogulas at wp dot pl
New email:
PHP Version: OS:

 

 [2008-03-23 14:23 UTC] gogulas at wp dot pl
Description:
------------
Hello,
here is script which egenerate error:
"Cannot use string offset as an array"
in line "while ($out[0][$ile] != 0){"
when i uncoment:
//echo "ok";
//exit;
the script gonna ignore problem and echo "ok"...

//var_dump ($outjs);
print a normal array, everything seems to be good, plase explain that, IMO this is a bug, thank you.


Reproduce code:
---------------
This is just a part of code, source of script are getable here: http://gogulas.yoyo.pl/array_bug_script.txt

<?php
(...)
	preg_match_all("/(.)=(.);/", $dane, $outjs, PREG_PATTERN_ORDER);
	preg_match_all("/([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})<script type=\"text\/javascript\">document.write\(\":\"(.*?)\)<\/script>/", $dane, $out, PREG_PATTERN_ORDER);
	fclose($fp);
	$ile = "0";
	while ($out[0][$ile] != 0){
		$out[5][$ile] = str_replace("+", "", $out[5][$ile]);
		$ilejs = "0";
//echo "<pre>";
//var_dump ($outjs);
//echo "</pre>";
//exit;
			while ( $outjs[2][$ilejs] > 0 ){
				//echo "ok";
				//exit;
				$out[5][$ile] = str_replace($outjs[1][$ilejs], $outjs[2][$ilejs], $out[5][$ile]);
				echo "ok";
				exit;
				$ilejs++;}
(...) ?>

Expected result:
----------------
I expected that the script gonna work fine.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-23 14:56 UTC] felipe@php.net
The erros is with $out, not $outjs. 
Then, put the var_dump($out); before the line: while ($out[0][$ile] != 0) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC