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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Sep 20 02:00:01 2025 UTC